×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Jul 2003
    Posts
    190

    Problem creating FEP-aware text control

    I'm creating text-entry control, inherited from CCoeControl.
    It implements CCoeControl::InputCapabilities, supplying pointer to class specializing MCoeFepAwareTextEditor, by which I wish to communicate with FEP to enter text to my control.

    Problem: as soon as I provide pointer to my class inherited from MCoeFepAwareTextEditor, I get crash in t9fep.dll, which reads from some NULL-pointer.
    I've tried inheriting control from CEikEdwin, then all works fine - it also provides its specialized MCoeFepAwareTextEditor, and it doesn't crash. But I need my own text control, not inheriting from CEikEdwin, so I must find a solution.

    What am I doing wrong??? Please help experts.

  2. #2
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,166
    basically you need to provide some more interfaceses in your control. Just check the Edwin header and trace down all interfaces it is implementing (and all interfaces implemented in classes the edwin in derived from).

    I think best way would first to implement all with empty functions, so you get it working. Then take them out one -by-one to see the minimal requirements to get it working.

    yucca

  3. #3
    Registered User
    Join Date
    Jul 2003
    Posts
    190
    Thanks. I actually made it work few hours later. Problem was that in Series60, MCoeFepAwareTextEditor::Extension1 must return pointer to CAknEdwinState, because T9 FEP depends on it. But docs say something else.

    A good thing was to study sourcode of FepExample (from nokia website), having look from 'other side'. This contains reference FEP, which I believe contains portions of code from real T9 FEP. It makes all things I missed - calling Extension1, casting CState to CAknEdwinState, etc.

    The Symbian Docs is crap, one has to try, crash, try, move on, try, crash, step back, .... until finding how it was intented to work.

    The positive thing about all this is that I will be able to make a custom-drawn text editor utilizing T9!!! That's I was looking for all the time.

  4. #4
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    Here is some (not so beautiful) example code on how to implement a custom control that can receive single characters.

    -----------------------------------------------------------------
    .h:


    #include <coecntrl.h>
    #include <fepbase.h>

    class FepExt1;

    class CTestContainer : public CCoeControl, MCoeFepAwareTextEditor
    {
    public:
    void ConstructL(const TRect& aRect);
    ~CTestContainer();

    // ...other stuff

    // these get called during editing
    //user commited a new char
    void EnterChar(TChar aChar);
    //user is cycling through chars, it needs to be shown
    void EnterEditChar(TChar aChar);
    //editing the char was canceled, remove it
    void CancelEditChar();

    TCoeInputCapabilities InputCapabilities() const;
    // fep stuff
    void StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit);
    void UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText);
    void SetInlineEditingCursorVisibilityL(TBool aCursorVisibility);
    void CommitFepInlineEditL(CCoeEnv& aConeEnvironment);
    void CancelFepInlineEdit();
    TInt DocumentLengthForFep() const;
    TInt DocumentMaximumLengthForFep() const;
    void SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection);
    void GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const;
    void GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const;
    void GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const;
    void GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt aDocumentPosition) const;
    MCoeFepAwareTextEditor_Extension1* Extension1();
    private:
    void DoCommitFepInlineEditL();
    MCoeFepAwareTextEditor_Extension1* Extension1(TBool& aSetToTrue);
    void MCoeFepAwareTextEditor_Reserved_2();
    private:
    // other stuff
    FepExt1* iFepExt;
    TBuf<2> iEditChar;
    TBool iEditing;

    };

    -----------------------------------------------------------------
    .cpp:

    #include "testcontainer.h"
    #include <aknedsts.h>

    // this class is needed just to return CAknEdwinState
    class FepExt1 : public MCoeFepAwareTextEditor_Extension1
    {
    CState* State(TUid aTypeSafetyUid) { return iEdwinState; }
    public:
    void SetStateTransferingOwnershipL(CState* aState, TUid aTypeSafetyUid) {}
    Ext1() { }
    void StartFepInlineEditL(TBool& aSetToTrue, const TCursorSelection& aCursorSelection, const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit) {
    aSetToTrue = ETrue;
    }
    void SetCursorType(TBool& aSetToTrue, const TTextCursor& aTextCursor) {
    aSetToTrue = ETrue;
    }
    MCoeFepLayDocExtension* GetFepLayDocExtension(TBool& aSetToTrue) {
    aSetToTrue = ETrue;
    return 0;
    }
    void MCoeFepAwareTextEditor_Extension1_Reserved_4() {}

    CAknEdwinState* iEdwinState;
    };


    void CTestContainer::ConstructL(const TRect& aRect)
    {
    // other construct stuff here

    iFepExt = new (ELeave) FepExt1();
    iFepExt->iEdwinState = new (ELeave) CAknEdwinState();
    iFepExt->iEdwinState->SetObjectProvider(this);
    iFepExt->iEdwinState->SetDefaultCase(EAknEditorLowerCase);
    iFepExt->iEdwinState->SetFlags(EAknEditorFlagNoLRNavigation
    |EAknEditorFlagNoEditIndicators);
    }

    CTestContainer::~CTestContainer()
    {
    // ....
    delete iFepExt;
    }

    TCoeInputCapabilities CTestContainer::InputCapabilities() const
    {
    /*
    // you can disable editing here if text needs to go somewhere else
    if (iListBox->IsVisible() )
    return TCoeInputCapabilities(TCoeInputCapabilities::ENone);*/

    TCoeInputCapabilities cap(
    TCoeInputCapabilities::EAllText,
    const_cast<CTestContainer*>(this), 0);

    return cap;
    }

    void CTestContainer::DoCommitFepInlineEditL() {
    if (iEditChar.Length()>0 && iEditing)
    {
    //final char
    RDebug::Print(_L("got char: %S"),&iEditChar);
    EnterChar(iEditChar[0]);
    iEditing = EFalse;
    }
    }
    void CTestContainer::StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
    {
    iEditChar = aInitialInlineText;
    iEditing = ETrue;
    }
    void CTestContainer::UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText) {
    //RDebug::Print(_L("update: %S"),&aNewInlineText);
    iEditChar = aNewInlineText;
    if (iEditChar.Length()>0)
    {
    //draw the char that is being edited here
    EnterEditChar(iEditChar[0]);
    }
    }
    void CTestContainer::SetInlineEditingCursorVisibilityL(TBool aCursorVisibility) {
    }
    void CTestContainer::CommitFepInlineEditL(CCoeEnv& aConeEnvironment) {
    }
    void CTestContainer::CancelFepInlineEdit() {
    // cancel editing
    CancelEditChar();
    iEditing = EFalse;
    }
    TInt CTestContainer::DocumentLengthForFep() const {
    return 0;
    }
    TInt CTestContainer::DocumentMaximumLengthForFep() const {
    return 1;
    }
    void CTestContainer::SetCursorSelectionForFepL(const TCursorSelection& aCursorSelection) {
    }
    void CTestContainer::GetCursorSelectionForFep(TCursorSelection& aCursorSelection) const {
    aCursorSelection.iCursorPos=1;
    aCursorSelection.iAnchorPos=1;
    }
    void CTestContainer::GetEditorContentForFep(TDes& aEditorContent, TInt aDocumentPosition, TInt aLengthToRetrieve) const {
    if (aLengthToRetrieve==1)
    aEditorContent=iEditChar;
    }
    void CTestContainer::GetFormatForFep(TCharFormat& aFormat, TInt aDocumentPosition) const {
    }
    void CTestContainer::GetScreenCoordinatesForFepL(TPoint& aLeftSideOfBaseLine, TInt& aHeight, TInt& aAscent, TInt aDocumentPosition) const {
    }

    MCoeFepAwareTextEditor_Extension1* CTestContainer::Extension1() {
    return iFepExt;
    }

    MCoeFepAwareTextEditor_Extension1* CTestContainer::Extension1(TBool& aSetToTrue) {
    aSetToTrue = ETrue;
    return iFepExt;
    }
    void CTestContainer::MCoeFepAwareTextEditor_Reserved_2() {
    }

  5. #5
    Registered User
    Join Date
    Mar 2003
    Posts
    2
    I later noticed that code above crashes if the dictionary is enabled. This can be fixed by setting EAknEditorFlagNoT9 flag too (or by writing much more complete callback implementations).

    iFepExt->iEdwinState->SetFlags(EAknEditorFlagNoLRNavigation|EAknEditorFlagNoEditIndicators|EAknEditorFlagNoT9);

  6. #6
    Registered User
    Join Date
    Jul 2003
    Posts
    190
    One more problem: the FEP's lower/upper case/T9 mode can be changed by # key. But how do you get the current FEP mode (if you want to display it in fullscreen app)?

    That's last issue why i can't use built-in FEP in my program.

  7. #7
    Registered User
    Join Date
    Jul 2003
    Posts
    190
    What does EAknEditorFlagNoLRNavigation do?

  8. #8
    Registered User
    Join Date
    Nov 2010
    Posts
    1

    Re: Problem creating FEP-aware text control

    Hi all,

    I want to display the typed characters in my application's view and not in any built in editors. I use OfferKeyEventL function to capture key events. I was able to receive key events in my application, But only numbers were received by the application. So I used the code provided by janttkoi to let FEP process the key events and provide correct keys to my application. This worked quietly good but the multitaping is not handled by the FEP. For eg. when I want to type acb the text received keys are aabcab ie when I type a, a is displayed. But when I need to type c, I need to type 2 three times. For each key press the key code is generated.

    Following is the sample code I used

    void CFirstGUIAppAppView::DoCommitFepInlineEditL()
    {
    if(desBuf.Length()>0)
    DrawNow();
    }
    void CFirstGUIAppAppView::StartFepInlineEditL(const TDesC& aInitialInlineText, TInt aPositionOfInsertionPointInInlineText, TBool aCursorVisibility, const MFormCustomDraw* aCustomDraw, MFepInlineTextFormatRetriever& aInlineTextFormatRetriever, MFepPointerEventHandlerDuringInlineEdit& aPointerEventHandlerDuringInlineEdit)
    {
    tempBuf=aInitialInlineText;
    //DrawNow();
    }
    void CFirstGUIAppAppView::UpdateFepInlineTextL(const TDesC& aNewInlineText, TInt aPositionOfInsertionPointInInlineText)
    {
    tempBuf=aNewInlineText;
    desBuf.Append(tempBuf);
    if(tempBuf.Length()>0)
    {
    DrawNow();
    }
    }

    All the other part of code is same as the code in the previous post.



    I am held up with this for more than three days. Experts please help.


    Thanks,
    devsymb.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×