problem with listbox event
| Wed, 2005-04-27 11:14 | |
|
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() ![]() I am kinda new with symbian:) |
|







Forum posts: 1379
i.e.
TKeyResponse CFTestDiskContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent, TEventCode aType )
{
return iListBox->OfferKeyEventL(aKeyEvent, aType);
}
didster
Forum posts: 15
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;
}
Forum posts: 1379
didster
Forum posts: 45
Though I'd follow didster's advice anyway, to make sure the events are redirected first place.
David.-
Forum posts: 90
AddToStackL( iListBox ) ?
savaaZ
For quality Symbian idling, join #symbian at irc.freenode.net
Forum posts: 17
*************************************************
*/
// 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"));
}
}
*************************************************
Forum posts: 83
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
Forum posts: 76
iList->SetListBoxObserver(this);
??
..
KiraN Puranik