problem with listbox event

Login to reply to this topic.
Wed, 2005-04-27 11:14
Joined: 2005-04-18
Forum posts: 15
I try to do list box event like this:
Code:

void CFTestDiskContainer::HandleListBoxEventL(
   CEikListBox*   iListbox/*aListBox*/,
   TListBoxEvent  iListBoxEvent/*aEventType*/ )
   {

//TInt index = iListBox->CurrentItemIndex();



if(iListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed)
{
 _LIT(message,"hello!");

           CAknInformationNote* informa tionNote = new (ELeave) CAknInformationNote;
           informationNote->ExecuteLD(message);
}
}

it compiles fine but nothing happens when i press emulators ok/select button.

what is the problem i have  this line in constructL()



Code:

iListBox->SetListBoxObserver( this );

should i have something about the enter button in OfferkeyEventL()

Huh

I am kinda new with symbian:)

Wed, 2005-04-27 11:35
Joined: 2004-07-28
Forum posts: 1379
problem with listbox event
Are you passing the keys passed into CYourContainer::OfferKeyEventL onto the listbox?

i.e.

TKeyResponse CFTestDiskContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
   {
   return iListBox->OfferKeyEventL(aKeyEvent, aType);
   }

didster

Wed, 2005-04-27 12:10
Joined: 2005-04-18
Forum posts: 15
problem with listbox event
yes ,that part of code looks like this


Code:
TKeyResponse CContainer::OfferKeyEventL(
                                      const TKeyEvent& aKeyEvent,
                                      TEventCode aType )
   {
   if ( aType != EEventKey )
       {
       return EKeyWasNotConsumed;
       }


   switch ( aKeyEvent.iCode )
       {
       // Up & Down arrow key's event transfer to list box
       case EKeyUpArrow:
           if ( iListBox )
               {
               return iListBox->OfferKeyEventL( aKeyEvent, aType );
               }
case EKeyDownArrow:
           if ( iListBox )
               {
               return iListBox->OfferKeyEventL( aKeyEvent, aType );
               }
           break;
case EAknSoftkeyOk:


               return iListBox->OfferKeyEventL( aKeyEvent, aType );
           break;

case EKeyEnter:
           if ( iListBox )
               {
               return iListBox->OfferKeyEventL( aKeyEvent, aType );
               }
           break;

       default:
               //return iListBox->OfferKeyEventL( aKeyEvent, aType );
break;
       }

   return EKeyWasNotConsumed;
   }
Code:
Wed, 2005-04-27 12:12
Joined: 2004-07-28
Forum posts: 1379
problem with listbox event
Try just unconditionally passing every key to the list box.

didster

Wed, 2005-04-27 12:32
Forum Nokia Champion
Joined: 2005-02-16
Forum posts: 45
problem with listbox event
...or use EKeyOK instead.

Though I'd follow didster's advice anyway, to make sure the events are redirected first place.

David.-
Wed, 2005-04-27 13:13
Joined: 2004-07-12
Forum posts: 90
problem with listbox event
Have you added the listbox into control stack?

AddToStackL( iListBox ) ?


savaaZ

For quality Symbian idling, join #symbian at irc.freenode.net

Thu, 2005-04-28 14:05
Joined: 2004-09-09
Forum posts: 17
Example code for help
Here is a working code in the container...... it might help you or other people Smiley


*************************************************

*/

// INCLUDE FILES
#include "Test1Container.h"

#include <eiklabel.h>  // for example label control
#include <aknnavi.h>   //EDDY
#include <barsread.h>   //EDDY
#include <aknnotewrappers.h>   //EDDY
#include <e32std.h>      //EDDY
#include <test1.rsg>      //EDDY

// ================= MEMBER FUNCTIONS =======================

// ---------------------------------------------------------
// CTest1Container::ConstructL(const TRect& aRect)
// EPOC two phased constructor
// ---------------------------------------------------------
//
void CTest1Container::ConstructL(const TRect& aRect)
   {
   CreateWindowL();

   CreateListL();

   SetRect(aRect);
   ActivateL();
   }

// Destructor
CTest1Container::~CTest1Container()
   {
   delete iMyListBox;
   }

// ---------------------------------------------------------
// CTest1Container::SizeChanged()
// Called by framework when the view size is changed
// ---------------------------------------------------------
//
void CTest1Container::SizeChanged()
   {
   // TODO: Add here control resize code etc.
   iMyListBox->SetExtent(TPoint(0,0), iMyListBox->MinimumSize());
   }

// ---------------------------------------------------------
// CTest1Container::CountComponentControls() const
// ---------------------------------------------------------
//
TInt CTest1Container::CountComponentControls() const
   {
   return 1; // return nbr of controls inside this container
   }

// ---------------------------------------------------------
// CTest1Container::ComponentControl(TInt aIndex) const
// ---------------------------------------------------------
//
CCoeControl* CTest1Container::ComponentControl(TInt aIndex) const
   {
   switch ( aIndex )
       {
      case 0:
         return iMyListBox;
      default:
           return NULL;
       }
   }

// ---------------------------------------------------------
// CTest1Container::Draw(const TRect& aRect) const
// ---------------------------------------------------------
//
void CTest1Container::Draw(const TRect& aRect) const
   {
   CWindowGc& gc = SystemGc();
   // TODO: Add your drawing code here
   // example code...
   gc.SetPenStyle(CGraphicsContext::ENullPen);
   gc.SetBrushColor(KRgbWhite);
   gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
   gc.DrawRect(aRect);
   }

// ---------------------------------------------------------
// CTest1Container::HandleControlEventL(
//     CCoeControl* aControl,TCoeEvent aEventType)
// ---------------------------------------------------------
//
void CTest1Container::HandleControlEventL(
   CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
   {   
   // TODO: Add your control event handler code here
   }


void CTest1Container::CreateListL()
   {
   iMyListBox  = new (ELeave)CAknSingleStyleListBox();
   iMyListBox->SetContainerWindowL(*this);
   TResourceReader reader;
   iEikonEnv->CreateResourceReaderLC(reader, R_MY_LIST_BOX);
   //iMyListBox->SetObserver(this);
   iMyListBox->SetListBoxObserver(this);
   iMyListBox->ConstructFromResourceL(reader);
   CleanupStack::PopAndDestroy();
   iMyListBox->CreateScrollBarFrameL( ETrue );
   
   iFocusedControl = iMyListBox;
   }


TKeyResponse CTest1Container::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
{  
  if(iMyListBox)
   {
   return iFocusedControl->OfferKeyEventL(aKeyEvent, aType);
   }
  else
   {
   return EKeyWasNotConsumed;
   }
}

void CTest1Container::HandleListBoxEventL(CEikListBox* aListBox, MEikListBoxObserver::TListBoxEvent aListBoxEvent)
{
   if( aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed)
   {
      //if(iMyListBox->
      iEikonEnv->InfoMsg(_L("heyoooo"));
   }
}

*************************************************
Fri, 2005-06-24 16:17
Joined: 2004-12-31
Forum posts: 83
Re: problem with listbox event
hi all
i have done every thing suggested by nerdie except tht am creating listbox dynamicall and not from a resource.
still am not getting any response in HandleListBoxEventL().
i have also done this

((CCoeAppUi*)iEikonEnv->AppUi())->AddToStackL(iListBox);

but to no help

please suggest some thing


warm regards

saurabh

Thu, 2005-07-14 05:53
Joined: 2005-06-01
Forum posts: 76
Re: problem with listbox event
Have you tried ..

iList->SetListBoxObserver(this);

??

..
KiraN Puranik
  • Login to reply to this topic.