how to process the Listbox event

Login to reply to this topic.
Mon, 2006-07-31 03:43
Joined: 2006-04-01
Forum posts: 28
Hello, everybody:

I have been stuck by this problem for a long time Huh. I hope some expert can help me.

My app is an EbookReader. First, I use a Listbox to list the book items. My aim is when users click the OK button, the book can be opened in a TextEditor.

My problem is how to process the CLICK event and how to change the view fo  the two UI components. All the code I have referred is the use of only one component.

Hope for your guidance. Thanks for your reply!

Mon, 2006-07-31 07:50
Joined: 2005-08-08
Forum posts: 88
Re: how to process the Listbox event
Be more specific please....
Mon, 2006-07-31 09:02
Joined: 2006-04-01
Forum posts: 28
Re: how to process the Listbox event
This app's function is:

1)search books in specified folder;
2)create the Listbox items using the path of searched book;
3)select book item and call a RichTextEditor to display the content of the book

I have complete 2 phases, and meet a problem in the third phase - display the content of book. I don't know how to do HandleListBox event(that is to select item and change the Listbox view to a RichTextEditor) and how to construct the RichTextEditor.

Thank for your reply dragos_t  Smiley
Mon, 2006-07-31 10:58
Joined: 2005-08-08
Forum posts: 88
Re: how to process the Listbox event
You can use the MEikListBoxObserver in your view and in the observer function (HandleListBoxEventL() ) process the EEventItemKeyPressed to start the RichTextEditor if ok key pressed.

You can make that list public in your class view, to make it accesible from the appui and associate a command  to the ok key and process it in the HandleCommandL() in the app ui.

OR you can use OfferKeyEventL() from the current view and process the ok button there, but that`s if you have a simple view (with one or two editable elements), otherwise it`s harder to control.
Tue, 2006-08-01 04:11
Joined: 2006-04-01
Forum posts: 28
Re: how to process the Listbox event
Thanks dragos_t Smiley

    Your guidance is a big help for me. According your suggestion, I create a class CRichTextEditor. And in the AppView class, I give a function ReadBookL() as follow:
Code:
void CEBookReaderAppView::ReadBookL()
{

iEditor = CRichTextEditor::NewL();
iEditor->SetContainerWindowL(*this);
                // assign the format of book
const CPlainText::TTextOrganisation aTextOrganisation = CPlainText::EOrganiseByParagraph;//EOrganiseByLine
                // read a txt file for testing
TFileName filename(KFilePath);
iEditor->InsertFromTextFileL(filename,aTextOrganisation);

ActivateL();
}
Unfortunately, this code give me EIKON - EDWIN 5 panic. I have referred the SDK Doc about eikedwin.pan. It give these explanation:
The enumeration TEikEdwinPanic contains panics relating to Edwin controls. The enumeration comprises: 

EEikPanicEdwinNoWidth - not used

EEikPanicEdwinNoHeight - not used

EEikPanicEdwinNotRichText - not used

EEikPanicEdwinNotOwnCharFormat - not used

EEikPanicEdwinNotOwnParaFormat - not used

EEikPanicEdwinNoView - no associated text view object

EEikPanicEdwinBadAttribute - not used

EEikPanicEdwinBadClipboardFunc - unknown clipboard function -not defined by TClipboardFunc

EEikPanicEdwinNoText - no associated plain text object

EEikPanicEdwinNoLayout - no associated CTextLayout object

EEikPanicEdwinNoWindow - not a window-owning control

EEikPanicEdwinInvalidTextLimit - document limit exceeds the limit 

EEikPanicEdwinInvalidInsertPos - text insertion at an invalid position

EEikPanicEdwinInvalidNumberOfLines - an attempt to format an invalid number of lines 

EEikPanicEdwinAutoScrollOnWithMultiLineEdwin - not used


But I don't know the reason of this panic. Please give me some hints.
Thank you again!
Tue, 2006-08-01 10:04
Joined: 2005-08-08
Forum posts: 88
Re: how to process the Listbox event
Maybe iEditor->ActivateL() instead of ActivateL().
Wed, 2006-08-02 03:11
Joined: 2006-04-01
Forum posts: 28
Re: how to process the Listbox event
Hi,

According to the error code, I modify the ReadBookL() function as follow:

Code:
void CEBookReaderAppView::ReadBookL()
{
                //CreateWindowL();  <-This may cause the error.

iEditor = CRichTextEditor::NewL();
iEditor->SetContainerWindowL(*this);
TResourceReader reader;
iCoeEnv->CreateResourceReaderLC(reader, R_RICHTEXTEDITOR_EDITOR);
ConstructFromResourceL(reader);
CleanupStack::PopAndDestroy(); // reader
SetFocus(ETrue);
const CPlainText::TTextOrganisation aTextOrganisation = CPlainText::EOrganiseByParagraph;//EOrganiseByLine
TFileName filename(KFilePath);
iEditor->InsertFromTextFileL(filename,aTextOrganisation);

ActivateL();
}

The error code means EEikPanicEdwinNoWindow - not a window-owning control . But In the ConstructL() function of CEBookReaderAppView class, there exists the CreateWindowL() method. So how should I modify the ReadBookL() function to make the EDWIN a window-owning control.

Thanks zillions for your reply.
Fri, 2006-08-04 08:12
Joined: 2006-01-18
Forum posts: 114
Re: how to process the Listbox event
hi,

here is the code to handle select items:

void CSypherSMSContainer2::HandleListBoxEventL(CEikListBox* /*aListBox*/, TListBoxEvent aListBoxEvent)
        {
        // if the Select Key has been pressed
        if (aListBoxEvent == MEikListBoxObserver::EEventEnterKeyPressed)
                {
                DisplaySelectedMenu();
                }
        }

void CSypherSMSContainer2::DisplaySelectedMenu()
    {
      TInt selectedIndex = iMainMenuListBox->CurrentItemIndex();
      switch (selectedIndex)
      {
         case 0:  // List item at 0
         {
            // Here is code to open EBook
            break;
         }
         
         case 1:  // List item at 1
         {
            // DISPLAY VIEW 2
           break;
         }
  • Login to reply to this topic.