×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    62

    how to getthe notification of selection of list box item??where towrite the handler

    hi
    i mtrying to display few items in listbox.my problem is how to get notification of selection of items. Will it differ if i create list box through Resource file
    any sample code will be higly appreciated
    thanks in advance

  2. #2
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    I'm not completely sure what do you mean, but if you want to do some action when a user clicks on an item in your listbox, then OfferKeyEventL is the method where you should look. For example like this:
    Code:
    TKeyResponse CMyContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
        {
    	TKeyResponse response;
    	response = iListBox->OfferKeyEventL(aKeyEvent, aType);
     	if(aType == EEventKeyDown)
    		{
    		switch ( aKeyEvent.iScanCode )
    			{
    			case EStdKeyEnter:
    			case EStdKeyDevice3:
    				//do something here
    				return EKeyWasConsumed;
    				break;
    			default:
    				break;
    			}
    		}
    	return response;
        }

  3. #3
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    62

    thanks sopta.

    hi sopta thanks i m getting back the key event for list box item selection. now next problem for me is how i can add the list item dynamically
    thanks in advance
    Last edited by jha_pankaj18; 2004-05-12 at 13:40.

  4. #4
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    You can access items through iListbox->Model()->... (probably ->ItemTextArray() or how it is called)
    Do not forget to call iListbox->HandleItemAdditionL() after you add a new item.
    I believe there is a nice example how to use listboxes somewhere in SDK...

  5. #5
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    62

    getting error while calling ReadDesCArrayResourceL(R_AKN_SCORE_LIST);

    hi sopta
    thanks for clue but i m getting run time error.
    As i clik on application icon i got "Program Closed E32User Cbase 18" while debuggin(VStudio6.0) i m getting error
    at the statement
    CDesCArray* textArray = iCoeEnv->ReadDesCArrayResourceL(R_AKN_SCORE_LIST);
    my complete code is like this


    CDemoContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();
    ///////////////////////////////////////////////////ListBox/////////////////////////////////

    iListBox = new (ELeave) CAknDoubleNumberStyleListBox;
    // iListBox->SetContainerWindowL( *this ); original

    iListBox->ConstructL(this, CEikListBox::EPopout | CEikListBox::ELeftDownInViewRect); //for dynamic creation


    //
    // Create the list from the resource file





    /////////////////dynamic //////////////////////////////////////////////////////////////////
    // CleanupStack::PopAndDestroy(); //rr

    //
    // Create a scrollbar that will be displayed automatically
    // if all the items cannot be displayed on screen
    //
    iListBox->CreateScrollBarFrameL(ETrue);
    iListBox->ScrollBarFrame()->SetScrollBarVisibilityL(CEikScrollBarFrame::EOff,CEikScrollBarFrame::EAuto);
    ///for dynamic creation
    CDesCArray* textArray = iCoeEnv->ReadDesCArrayResourceL(R_AKN_SCORE_LIST);
    iListBox->Model()->SetItemTextArray( textArray );
    iListBox->Model()->SetOwnershipType( ELbmOwnsItemArray );
    textArray = static_cast<CDesCArray*>( iListBox->Model()->ItemTextArray() );
    textArray->AppendL( _L("Item10") );
    iListBox->HandleItemAdditionL();


    //for dynamic creation ends here


    ///////////////////////////////////////////////ListBox/////////////////////////////////
    SetRect(aRect);
    ActivateL();
    }
    hoping for reply
    thanks

  6. #6
    Super Contributor
    Join Date
    Apr 2003
    Location
    Czech Republic
    Posts
    915
    CBase 18 = EArrayFixInvalidGranularity

    How does your resource (R_AKN_SCORE_LIST) looks like?
    btw, I believe that textArray should be of type CDesCArrayFlat (it is expected by ReadDesCArrayResourceL() method...

  7. #7
    Regular Contributor
    Join Date
    Feb 2004
    Posts
    62

    Evne i tried "CDesCArrayFlat()" same error

    hi spota,
    i tried the CDesCArrayFlat also i m getting same error.
    RESOURCE file declaration in my .rss file look like this


    RESOURCE LISTBOX r_akn_score_list
    {
    array_id = r_akn_score_list_items;
    flags = EAknListBoxSelectionList;
    }

    RESOURCE ARRAY r_akn_score_list_items
    {
    items =
    {
    LBUF
    {
    txt = str_default_score_entry1; // defined in EmbedDemo.loc
    },
    LBUF
    {
    txt = str_default_score_entry2;
    },
    LBUF
    {
    txt = str_default_score_entry3;
    },
    LBUF
    {
    txt = str_default_score_entry4;
    },
    LBUF
    {
    txt = str_default_score_entry5;
    },
    LBUF
    {
    txt = str_default_score_entry6;
    },
    LBUF
    {
    txt = str_default_score_entry7;
    },
    LBUF
    {
    txt = str_default_score_entry8;
    },
    LBUF
    {
    txt = str_default_score_entry9;
    }
    };
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×