ListBox: Part IX

9. ListBox Events
Keywords:

Whenever an event occurs, listbox can notify another object about it. That other object is called event handler or listbox observer, following GoF Observer pattern. ListBox observer can be any object that implements void HandleListBoxEventL(CEikListBox* listBox, TListBoxEvent eventType) method, so that listbox can invoke that method passing a pointer to itself and the information about the type of the event that happened.

HandleListBoxEventL method didn't have to be the only required method; listbox might have required from a listbox observer to implement other methods as well, even though it's not the case.

The way to specify what are the required observer methods is to create a class that lists them as pure virtual methods. Such class is called the observer interface, or the 'Mixin' in Symbian terminology.

The observer interface serves as a common point for objects that generate events and objects that receive events. Objects that generate events only know about the interface; they call virtual methods on it, without knowing or caring what is the exact object that implemented them. On the other side, objects that receive events inherit from the interface and implement methods specified in it in order to qualify as observers.

The observer interface is the essence of communication between the objects that otherwise might have nothing in common; any object can act as an observer of any other object, as long as it implements the observer interface defined by that other object.

Getting back to listbox -- MEikListBoxObserver is the observer interface that every object must implement in order to qualify as a listbox observer. Implementing MEikListBoxObserver interface means inheriting from MEikListBoxObserver class and implementing HandleListBoxEventL() method.

In our sample, ListBoxContainer (itself CCoeControl) implements MEikListBoxObserver interface in order to receive notifications from a listbox which happens to be its only child component.

ListBoxContainer registers itself as a listbox observer for a concrete listbox instance by calling listBox->SetListBoxObserver(this); Through observer's HandleListBoxEventL() method listbox sends the information about several different types of events, all defined in MEikListBoxObserver::TListBoxEvent enum:

EEventEnterKeyPressed
EEventItemClicked
EEventItemDoubleClicked
EEventItemActioned
EEventEditingStarted
EEventEditingStopped


:<: Part VIII


> ListBox: Part IX

Hi Klisa,

Tnx for your earlier reply :)

I added following code to my container code but it doesn't handle events

void CBancoContainer::HandleListBoxEventL(CEikListBox* listBox, TListBoxEvent eventType)

switch (eventType)

case EEventEnterKeyPressed : iEikonEnv->InfoMsg(_L("EEventEnterKeyPressed")); break;

case EEventItemClicked: iEikonEnv->InfoMsg(_L("EEventItemDoubleClicked")); break;

case EEventItemActioned: iEikonEnv->InfoMsg(_L("EEventItemActioned")); break;

case EEventEditingStarted: iEikonEnv->InfoMsg(_L("EEventEditingStarted")); break;

case EEventEditingStopped: iEikonEnv->InfoMsg(_L("EEventEditingStopped")); break;

;

Are there more to configure or tuneup? Please help me ... I'm very new to symbian

tnx,

Pramoda

> ListBox: Part IX

Hi

U have to use the mouse pointer to select the list box items. :)

Titan

> ListBox: Part IX

Hi,

Your code seems to be ok asuming that you have only one listbox in your application. Check whether you have set the list box observer to container by the method list->SetListBoxObserver(this);

thx, Santosh Shetty.

> ListBox: Part IX

Nice article! Maybe this is the solution to my problem. But first, before wasting my time with something that doesn't work, I'd like to know:

1. Is there any article/example that shows how to build a SettingItemlist without using resource files?

2. Is this the only way I can have a EnumeratedTextPopupSettingItem with dynamic values (e.g. list of IAPs)?

3. If ListBox is the way to go, I'll still have to know how to manage editions (radio buttons select list, date/time editors...). Are there any methods that implements this for each SettingItem? Or should I manage it by using events (clicking a setting item makes a popup dialog show up...)?

Thanks in advance.

> ListBox: Part IX

hi i just wanted to know can we have a selection list created dynamically or notifier with 3 buttons (RNotifier is there but taht is with 2 buttons) without using resource file in uiq if yes then how can we do that?? plz tell if anybody does know

thanks a lot

> ListBox: Part IX

I have defined the listbox in a dialog in .RSS file .

Now i want to read the selected value in the list Box .

I have obtained the pointer to the CEikListBox also ... But if i use CurrentItemIndex() it returns the index of the selected Item.

My problem is how to read the value(Text) at that selected index

Re: ListBox: Part IX

I am facing a problem like i hav created the CAknSingleGraphicStyleListBox listbox of base class CCoeControl and MEikListBoxObserver
but when i am pressing the item in the list item i am not able to switch to other view and i am getting Kern Exec 3 panic.

what can i do?