AppUi -> View -> CCoeControl Event Handling
| Mon, 2005-03-28 13:44 | |
|
I have a following implementation:
- AppUi creates View (CCoeControl, MCoeControlObserver) - View creates Container (CCoeControl, MEikListBoxObserver) - Container creates (and manages) ListBox Now, I've succeeded in getting all this created, listbox is visible, and I can scroll it with the scrollbar.The menubar (handled by AppUi) also works fine. The problem is, I can't choose items from the list. The list doesn't seem to activate at all. View is Window-owning (ie. it calls CreateWindowL), and Container is set to the View (with SetContainerWindowL). The Listbox is set to the Container (with SetContainerWindowL). When I tried making the Container a window-owning control, I gained focus for the listbox, but also a multitude of either CONE 10's or EIKCTL 42s. I guess this has something to do with either command/control stack or windows, but thus far I haven't been able to track it down. Help is greatly appreciated! |
|






Forum posts: 85
Your question isn't very clear. Did you actually add any items to your Listbox? Can you see anything to choose?
You say the scrollbar works. I guess that means you do have items in there. Then, what do you mean by "the list isn't active at all"? What are you trying to do? Do you mean you use "up/down" buttons to highlight an item and then click on "OK" button, but nothing is happening?
Forum posts: 39
I've tried tracking the functionality with checkpoints, and according to those tapping on screen or pressing keys simply doesn't call any action handler. Not HandleListBoxEventL on Container, HandleControlEventL on View nor HandleCommandL on AppUi. So I guess either the action isn't caught at all, or simply isn't handled anywhere.
Here are the ConstructL-methods for View:
{
CreateWindowL();
SetRect(aRect);
iContainer = new(ELeave) CMyAppContainer();
iContainer->SetContainerWindowL(*this);
iContainer->ConstructL(aRect);
iContainer->SetObserver(this);
ActivateL();
iContainer->FillListBoxL();
}
and Container:
{
iDocument = static_cast <CMyAppDocument*>
(CEikonEnv::Static()->EikAppUi()->Document());
iListBox = new (ELeave) CEikColumnListBox;
iListBox->SetContainerWindowL(*this);
iListBox->ConstructL(this,0);
// Create scrollbars
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
iListBox->SetSize(aRect.Size());
iListBox->SetListBoxObserver(this);
TParse parse;
parse.Set(CEikonEnv::Static()->EikAppUi()->Application()->AppFullName(), NULL, NULL);
iIconFileName.Copy(parse.DriveAndPath());
iIconFileName.Append(_L("icons.mbm"));
CArrayPtr<CGulIcon>* icons = new(ELeave) CArrayPtrFlat<CGulIcon>(4);
icons->AppendL(iEikonEnv->CreateIconL(iIconFileName,0,1));
icons->AppendL(iEikonEnv->CreateIconL(iIconFileName,2,3));
TInt width = aRect.Width();
TInt iconWidth = 25;
CColumnListBoxData* pColumnData = iListBox->ItemDrawer()->ColumnData();
pColumnData->SetIconArray(icons);
pColumnData->SetGraphicsColumnL(0,ETrue);
pColumnData->SetColumnWidthPixelL(0,iconWidth);
pColumnData->SetGraphicsColumnL(1,EFalse);
pColumnData->SetColumnWidthPixelL(1,width - iconWidth);
iListBox->View()->ItemDrawer()->SetDrawMark(EFalse);
iListBox->Reset();
ActivateL();
// Sets the focus and activates listbox
iListBox->SetFocus(ETrue);
iListBox->DrawNow();
}
Did that clarify anything?
Forum posts: 188
Your problem may be because, the following(or any one of following) are missing.
1) Have you put your view on to view stack in appui after creating the view?
2) Have you implemented the OfferKeyEventL in your Container containing ListBox and if yes than are you passing those keyevents to your listbox.
check weather you have implemented above functionality or not.
BR
Chetan
----
Chetan Kulshrestha
Forum posts: 19
Forum posts: 39
I also think this is something to do with the command stack, but I'm not certain about the AddToStackL() command, since as I've understood it, it is an AppUi-only command (?), and the Container is supposed to be "over" AppView. I did try calling AddToStackL() in AppView, but it wouldn't compile.
Forum posts: 39
The code is as follows:
{
CreateWindowL();
SetRect(aRect);
iContainer = new(ELeave) CUiqMyContainer();
iContainer->SetContainerWindowL(*this);
iContainer->ConstructL(aRect);
iContainer->SetObserver(this);
iEikonEnv->EikAppUi()->AddToStackL(iContainer);
ActivateL();
iContainer->FillListBoxL();
}
Now, the only problem left is, that I cannot get the Container/Listbox to accept pointer events. As seen in the code copied earlier, I've set the Container as a ListBoxObserver, and have tried adding HandlePointerEventL() to Container, but nothing seems to help.
I think this might be due to the Container not being a window-owning control. This is because the View calls CreateWindowL(), so cannot do the same for Container. But I haven't found out another way of doing this..
Advice appreciated.
/Cir
Forum posts: 39
* I was correct, the listbox didn't take pointer events, because the Container wasn't a window-owning control.
Now the problem is as follows: to make the Container a window-owning control, I had to dump the AppView's "CreateWindowL" and "iContainer->SetContainerWindowL" -calls. Now I can take both key presses and pointer events to the listbox, but
a) the Container is drawn to a wrong place! It's covering the menubar, and the "background" is peeking through in the bottom.
Please, I'm so close, but sooooo tired to butting my head to the wall. Please, help!
/Cir
Forum posts: 2
Hello,Cir:
You have said that you could get both key events and pointer events. Have you override the HandlePointerEventL function and written it in your own code? Have you set a breakpoint in it and got the point events in it?