|
|
User login
Feeds |
Listbox not responding to keyboard enter / emualtor OK
|
|||||
| Sun, 2004-12-12 18:59 | |
|
I have a listbox and it is not responding to keyboard enter key / emualtor OK button. Why? Here's the code:
Container class' ConstructL function: Code: iListBox = new(ELeave) CAknSingleStyleListBox(); iListBox->SetContainerWindowL(*this); iListBox->SetMopParent(this); TResourceReader reader; CEikonEnv::Static()->CreateResourceReaderLC(reader, R_INITIAL_SELECTION_LIST); iListBox->ConstructFromResourceL(reader); CleanupStack::PopAndDestroy(); //Creates scrollbar iListBox->CreateScrollBarFrameL(ETrue); iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto); TInt pos(iListBox->View()->CurrentItemIndex()); if (iListBox->ScrollBarFrame()) iListBox->ScrollBarFrame()->MoveVertThumbTo(pos); if (iListBox->IsNonFocusing()) { _L(""); //Does not go in here } iListBox->SetFocusing(ETrue); iListBox->SetFocus(ETrue); SetRect(aRect); ActivateL(); Code: void CTerminalAppContainer:: HandleListBoxEventL(CEikListBox* aListBox, TListBoxEvent aEventType) { ; //Have a breakpoint here, but it never stops } Code: TKeyResponse CTerminalAppContainer:: OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType) { return iListBox->OfferKeyEventL(aKeyEvent, aType); //I found out that this line has to be here to recognize the arrow keys / button(s) } TInt CTerminalAppContainer::CountComponentControls() const { return 1; } CCoeControl* CTerminalAppContainer::ComponentControl(TInt aIndex) const { switch (aIndex) { case 0 : return iListBox; default: return NULL; } } void CTerminalAppContainer::Draw(const TRect& aRect) const { CWindowGc& gc = SystemGc(); gc.SetPenStyle(CGraphicsContext::ENullPen); gc.SetBrushColor(KRgbGray); gc.SetBrushStyle(CGraphicsContext::ESolidBrush); gc.DrawRect(Rect()); } The resource file includes: Code: RESOURCE LISTBOX r_initial_selection_list { array_id = r_initial_selection_array; flags = EAknListBoxSelectionList; } RESOURCE ARRAY r_initial_selection_array { items = { LBUF { txt = qtn_initial_option_get_address; }, LBUF { txt = qtn_initial_option_get_addresses; }, LBUF { txt = qtn_initial_option_get_operator; } }; } #define qtn_initial_option_get_address "\tHämta adress\t\t" #define qtn_initial_option_get_addresses "\tUppdatera adressbok\t\t" #define qtn_initial_option_get_operator "\tVälj operatör\t\t" |
|
Forum posts: 15
((CCoeAppUi*)iEikonEnv->AppUi())->AddToStackL(yourControl);
Forum posts: 83
i am facing the similar problem. i tried what Mo suggested but its not working. if u have found the solution please help.
warm regards
saurabh
Forum posts: 982
i am facing the similar problem. i tried what Mo suggested but its not working. if u have found the solution please help.
What should your listbox do when you press ' keyboard enter key / emualtor OK button" ? In joape's code there is CAknSingleStyleListBox so what should happen when pressing ok?
Saurabh....do you have there a selection/multiselection listbox? Or a SettingListBox? Or?
pirosl
Forum posts: 83
i have multiselection listbox. and want to know what all selection the user have made.
warm regards
saurabh
Forum posts: 982
pirosl
Forum posts: 83
void CAddContainer::ConstructL(const TRect& aRect)
{
CreateWindowL();
// Create the list
CreateListBoxL();
// Set the icons in the list's drawer
SetListBoxIconArrayL();
// Set up scroll bars
SetupScrollBarsL();
// Set the list items
SetupListItemsL();
CreateFindBoxL();
SetRect(aRect);
ActivateL();
}
void CAddContainer::CreateListBoxL()
{
iListBox = new(ELeave)CAknSingleGraphicStyleListBox ;
iListBox->ConstructL(this,EAknListBoxMultiselectionList );
iListBox->SetContainerWindowL(*this);
iListBox->SetListBoxObserver(this);
// ((CCoeAppUi*)iEikonEnv->AppUi())->AddToStackL(this);
}
void CAddContainer::SetListBoxIconArrayL()
{
CArrayPtr<CGulIcon>* icons =new( ELeave ) CAknIconArray(KNumberOfIcons);
CleanupStack::PushL(icons);
_LIT(KChkBxImg, "\\system\\apps\\try\\chk_bx.mbm");
_LIT(KImg, "\\system\\apps\\try\\image.mbm");
icons->AppendL(iEikonEnv->CreateIconL(KChkBxImg, EMbmChkbxChk, EMbmChkbxChk_mask));
icons->AppendL(iEikonEnv->CreateIconL(KChkBxImg, EMbmChkbxUn_chk, EMbmChkbxChk_mask));
icons->AppendL(iEikonEnv->CreateIconL(KImg, EMbm0, EMbm0_mask));
icons->AppendL(iEikonEnv->CreateIconL(KImg, EMbm1, EMbm1_mask));
icons->AppendL(iEikonEnv->CreateIconL(KImg, EMbm2, EMbm2_mask));
icons->AppendL(iEikonEnv->CreateIconL(KImg, EMbm3, EMbm3_mask));
CleanupStack::Pop(icons);
iListBox->ItemDrawer()->ColumnData()->SetIconArray(icons); // passing ownership of icons
}
void CAddContainer::SetupScrollBarsL()
{
iListBox->CreateScrollBarFrameL(ETrue);
iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(
CEikScrollBarFrame::EOff, CEikScrollBarFrame::EAuto);
}
void CAddContainer::SetupListItemsL()
{
CDesCArrayFlat *listBoxItems = new CDesCArrayFlat(KListSize);
TBuf<256> item;
TBuf<20> name(_L("ABC"));
item.Format(_L("%d\t%S\t%d"), 1 , &name, 4);
listBoxItems->AppendL(item);
name = _L("BCD");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 3);
listBoxItems->AppendL(item);
name = _L("CDE");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 4);
listBoxItems->AppendL(item);
name = _L("DEF");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 4);
listBoxItems->AppendL(item);
name = _L("EFG");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 2);
listBoxItems->AppendL(item);
name = _L("FGH");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 4);
listBoxItems->AppendL(item);
name = _L("GHI");
item.Format(_L("%d\t%S\t%d"), 1 , &name, 4);
listBoxItems->AppendL(item);
iListBox->Model()->SetItemTextArray(listBoxItems);
iListBox->Model()->SetOwnershipType(ELbmOwnsItemArray);
}
void CAddContainer::CreateFindBoxL()
{
CTextListBoxModel* aModel = iListBox->Model();
if ( iListBox && aModel )
{
// Gets pointer of CAknFilteredTextListBoxModel.
CAknFilteredTextListBoxModel* model = STATIC_CAST( CAknFilteredTextListBoxModel*, aModel );
// Creates FindBox.
iFindBox = CAknSearchField::NewL( *this, CAknSearchField::ESearch, NULL,
KAknExListFindBoxTextLength );
CleanupStack::PushL(iFindBox);
// Creates CAknListBoxFilterItems class.
model->CreateFilterL( iListBox, iFindBox );
//Filter can get by model->Filter();
CleanupStack::Pop(iFindBox); // findbox
// SizeChanged();
}
}
following are the size changed functions.
{
if (iListBox)
{
if (iFindBox)
{
SizeChangedForFindBox();
}
else
{
iListBox->SetRect(Rect()); // Sets rectangle of lstbox.
}
}
}
void CAddContainer::SizeChangedForFindBox()
{
if ( iListBox && iFindBox )
{
CAknColumnListBox* aknListBox = STATIC_CAST(CAknColumnListBox*, iListBox);
AknFind::HandleFixedFindSizeChanged(this, aknListBox, iFindBox);
}
}
and now i am not getting any event in the following function
CEikListBox* aListBox, TListBoxEvent aListBoxEvent)
{ /////have a break point here but of no use.
if ( aListBox == iListBox )
{
TInt x;
switch(aListBoxEvent)
{
case EEventItemClicked:
x =10;
break;
default:
break;
}
}
warm regards
saurabh
Forum posts: 83
warm regards
saurabh
Forum posts: 982
pirosl
Forum posts: 83
warm regards
saurabh
Forum posts: 982
pirosl
Forum posts: 83
warm regards
saurabh