Listbox not responding to keyboard enter / emualtor OK

Login to reply to this topic.
Sun, 2004-12-12 18:59
Joined: 2004-09-06
Forum posts: 349
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"

Tue, 2005-01-11 17:04
Joined: 2004-12-23
Forum posts: 15
Listbox not responding to keyboard enter / emualtor OK
try
((CCoeAppUi*)iEikonEnv->AppUi())->AddToStackL(yourControl);
Fri, 2005-06-24 14:30
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
hi joape382

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

Fri, 2005-06-24 14:47
Joined: 2004-05-24
Forum posts: 982
Re: Listbox not responding to keyboard enter / emualtor OK
Quote from: saurabh_gyl
hi joape382

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

Fri, 2005-06-24 16:20
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
hi pirosl

i have multiselection listbox. and want to know what all selection the user have made.

warm regards

saurabh

Sun, 2005-06-26 21:42
Joined: 2004-05-24
Forum posts: 982
Re: Listbox not responding to keyboard enter / emualtor OK
Can you show how you built your list?

pirosl

Tue, 2005-06-28 08:59
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
this is how i am creating the listbox. i am able to select multiple items but the problem is that i am not getting any callback in HandleLisBoxEventL() and dopnt know how get what all item have been selected.

Code:

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.

Code:
void CAddContainer::SizeChanged()
    {
    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

Code:
void CAddContainer::HandleListBoxEventL(
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

Fri, 2005-07-01 06:26
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
can admin please move this topic to series 60 forum cause i dont think many ppl are watching this here.

warm regards

saurabh

Fri, 2005-07-01 07:59
Joined: 2004-05-24
Forum posts: 982
Re: Listbox not responding to keyboard enter / emualtor OK
Very short question: does your CAddContainer extends/implements MEikListBoxObserver?

pirosl

Fri, 2005-07-01 10:24
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
yes of course

warm regards

saurabh

Fri, 2005-07-01 10:45
Joined: 2004-05-24
Forum posts: 982
Re: Listbox not responding to keyboard enter / emualtor OK
Is your list box focused?

pirosl

Fri, 2005-07-01 11:47
Joined: 2004-12-31
Forum posts: 83
Re: Listbox not responding to keyboard enter / emualtor OK
even doing
Code:
iListBox->SetFocus(ETrue)
   in the ContructL() of container is of no use.

warm regards

saurabh

  • Login to reply to this topic.