how to process the Listbox event
| Mon, 2006-07-31 03:43 | |
|
Hello, everybody:
I have been stuck by this problem for a long time . 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! |
|






. I hope some expert can help me.
Forum posts: 88
Forum posts: 28
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
Forum posts: 88
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.
Forum posts: 28
  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:
{
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();
}
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!
Forum posts: 88
Forum posts: 28
According to the error code, I modify the ReadBookL() function as follow:
{
        //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.
Forum posts: 114
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;
}