×

Discussion Board

Results 1 to 8 of 8
  1. #1
    Registered User
    Join Date
    Dec 2011
    Posts
    6

    Move focus from one Text Editor to another Text Editor

    Hi,

    Working environment: Carbide.c++ version 2.7 (Symbian S60 3rd edition FP2)

    I am working on small app which consist of 2 Input Filed (2 Text Editors) on UI, when screen loads up i am setting up one Text Editor setFocus() functionality to True, now on device when i click on another Text Editor cursor/focus does not get transferred to another Text Editor

    Any pointer or help on this would we greatly appreciated... Thank You

    ---
    Ankit Shah

  2. #2
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,103

    Re: Move focus from one Text Editor to another Text Editor

    Can you show how have you handled the switching between the text editors (in offerkeyeventL() i assume)

  3. #3
    Nokia Developer Expert
    Join Date
    Sep 2011
    Posts
    382

    Re: Move focus from one Text Editor to another Text Editor

    Dimmed editor would not receive the touch event. In general apps in non-touch phone emulators may not react to mouse "click", but only keys.

  4. #4
    Registered User
    Join Date
    Jul 2011
    Posts
    13

    Re: Move focus from one Text Editor to another Text Editor

    Hi All,

    Please check below code snippet to move focus from one TextEditor to another TextEditor in Symbian S60 3rd edition FP2 devices :

    =====================================

    #include <eikgted.h>
    #include <f32file.h>
    #include <txtglobl.h>
    #include <aknutils.h>

    #include "ExampleTextContainer.h"

    // CONSTANTS

    // ================= MEMBER FUNCTIONS =======================

    CExampleTextContainer::CExampleTextContainer()
    : iEditor(0)
    {
    }

    void CExampleTextContainer::ConstructL(const TRect& aRect)
    {
    CreateWindowL();

    // construct editor without resource
    iEditor = new (ELeave) CEikGlobalTextEditor;

    iEditor1 = new (ELeave) CEikGlobalTextEditor;


    // to get the scrollbar created automatically (based on the flag below)
    // we have to set avkon-flags *before* ConstructL-call
    //
    iEditor->SetAknEditorFlags( EAknEditorFlagEnableScrollBars
    | EAknEditorFlagNoLRNavigation);
    iEditor->ConstructL(
    this,
    0, // number of lines
    0, // text limit
    (EEikEdwinReadOnly | EEikEdwinAvkonDisableCursor | EEikEdwinNoAutoSelection), // edwin flags
    EGulFontControlAll, // font control flags
    EGulAllFonts ); // font name flags

    iEditor->SetFocus(ETrue);

    iEditor->TextLayout()->RestrictScrollToTopsOfLines( EFalse );


    iEditor1->SetAknEditorFlags( EAknEditorFlagEnableScrollBars
    | EAknEditorFlagNoLRNavigation);
    iEditor1->ConstructL(
    this,
    0, // number of lines
    0, // text limit
    (EEikEdwinReadOnly | EEikEdwinAvkonDisableCursor | EEikEdwinNoAutoSelection), // edwin flags
    EGulFontControlAll, // font control flags
    EGulAllFonts ); // font name flags


    iEditor1->SetFocus(EFalse);

    iEditor1->TextLayout()->RestrictScrollToTopsOfLines( EFalse );

    //iEditor->EnableCcpuSupportL(ETrue);
    ActivateL();
    SetRect(aRect);
    }

    CExampleTextContainer* CExampleTextContainer::NewL(const TRect& aRect)
    {
    CExampleTextContainer* self = new (ELeave) CExampleTextContainer();
    self->ConstructL(aRect);
    return self;
    }

    CExampleTextContainer::~CExampleTextContainer()
    {
    delete iEditor;
    delete iEditor1;
    }

    void CExampleTextContainer::SizeChanged()
    {
    TSize size = Size();

    iEditor->SetExtent(TPoint(20,10),TSize(260,100));

    iEditor1->SetExtent(TPoint(20,120),TSize(260,90));

    }

    void CExampleTextContainer::ActivateL()
    {

    TBuf<1000> Introbuf;
    Introbuf.Copy(_L("Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !! "));
    iEditor->SetTextL(&Introbuf);
    iEditor->SetCursorPosL(0,EFalse);

    TBuf<1000> Introbuf1;
    Introbuf1.Copy(_L("Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !! Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !!Hello World !! Hello World !! "));
    iEditor1->SetTextL(&Introbuf1);
    iEditor1->SetCursorPosL(0,EFalse);
    CCoeControl::ActivateL();

    }

    TInt CExampleTextContainer::CountComponentControls() const
    {
    return 2; // return number of controls inside this container
    }

    CCoeControl* CExampleTextContainer::ComponentControl(TInt aIndex) const
    {
    switch (aIndex)
    {
    case 0:
    return iEditor;
    case 1:
    return iEditor1;
    default:
    return NULL;
    }
    }

    void CExampleTextContainer::Draw(const TRect& aRect) const
    {
    CWindowGc& gc = SystemGc();
    gc.Clear(aRect);
    }

    TKeyResponse CExampleTextContainer::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType)
    {

    if(aKeyEvent.iCode == EKeyLeftArrow)
    {
    iEditor->SetFocus(ETrue);
    iEditor1->SetFocus(EFalse);
    }
    else if(aKeyEvent.iCode == EKeyRightArrow)
    {
    iEditor->SetFocus(EFalse);
    iEditor1->SetFocus(ETrue);
    }
    if(iEditor->IsFocused()) {
    if (iEditor)
    {
    if (aKeyEvent.iCode == EKeyDownArrow)
    {
    iEditor->TextView()->ScrollDisplayL(TCursorPosition::EFLineDown);
    iEditor->MoveDisplayL(TCursorPosition::EFLineDown);

    DrawNow();
    iEditor->DrawNow();
    return EKeyWasConsumed;
    }
    else if (aKeyEvent.iCode == EKeyUpArrow)
    {
    iEditor->TextView()->ScrollDisplayL(TCursorPosition::EFLineUp);
    iEditor->MoveDisplayL(TCursorPosition::EFLineUp);

    DrawNow();
    iEditor->DrawNow();
    return EKeyWasConsumed;
    }
    else
    {
    return iEditor->OfferKeyEventL(aKeyEvent, aType);
    }
    }
    else
    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
    }



    if(iEditor1->IsFocused())
    {

    if (iEditor1)
    {
    if (aKeyEvent.iCode == EKeyDownArrow)
    {
    iEditor1->TextView()->ScrollDisplayL(TCursorPosition::EFLineDown);
    iEditor1->MoveDisplayL(TCursorPosition::EFLineDown);

    DrawNow();
    iEditor1->DrawNow();
    return EKeyWasConsumed;
    }
    else if (aKeyEvent.iCode == EKeyUpArrow)
    {
    iEditor1->TextView()->ScrollDisplayL(TCursorPosition::EFLineUp);
    iEditor1->MoveDisplayL(TCursorPosition::EFLineUp);

    DrawNow();
    iEditor1->DrawNow();
    return EKeyWasConsumed;
    }
    else
    {
    return iEditor1->OfferKeyEventL(aKeyEvent, aType);
    }
    }
    else
    return CCoeControl::OfferKeyEventL(aKeyEvent, aType);
    }
    }


    void CExampleTextContainer::HandlePointerEventL(const TPointerEvent &aPointerEvent)
    {

    TPoint pos = aPointerEvent.iPosition;

    if((pos.iX > 20 && pos.iX < 280) && (pos.iY > 10 && pos.iY < 110))
    {
    iEditor->SetFocus(ETrue);
    iEditor1->SetFocus(EFalse);
    }
    else if((pos.iX > 20 && pos.iX < 280) && (pos.iY > 120 && pos.iY < 210))
    {
    iEditor->SetFocus(EFalse);
    iEditor1->SetFocus(ETrue);
    }

    if(iEditor->IsFocused()) {
    static TInt firstpoint;

    if(aPointerEvent.iType == TPointerEvent::EButton1Down)
    {
    firstpoint = aPointerEvent.iPosition.iY;
    }

    if(aPointerEvent.iType == TPointerEvent::EDrag)
    {
    if(aPointerEvent.iPosition.iY > firstpoint)
    {
    iEditor->TextView()->ScrollDisplayL(TCursorPosition::EFLineUp);
    iEditor->MoveDisplayL(TCursorPosition::EFLineUp);

    DrawNow();
    iEditor->DrawNow();

    }
    else
    {
    iEditor->TextView()->ScrollDisplayL(TCursorPosition::EFLineDown);
    iEditor->MoveDisplayL(TCursorPosition::EFLineDown);

    DrawNow();
    iEditor->DrawNow();

    }
    }
    }



    if(iEditor1->IsFocused()) {
    static TInt firstpoint;

    if(aPointerEvent.iType == TPointerEvent::EButton1Down)
    {
    firstpoint = aPointerEvent.iPosition.iY;
    }

    if(aPointerEvent.iType == TPointerEvent::EDrag)
    {
    if(aPointerEvent.iPosition.iY > firstpoint)
    {
    iEditor1->TextView()->ScrollDisplayL(TCursorPosition::EFLineUp);
    iEditor1->MoveDisplayL(TCursorPosition::EFLineUp);

    DrawNow();
    iEditor1->DrawNow();

    }
    else
    {
    iEditor1->TextView()->ScrollDisplayL(TCursorPosition::EFLineDown);
    iEditor1->MoveDisplayL(TCursorPosition::EFLineDown);

    DrawNow();
    iEditor1->DrawNow();

    }
    }
    }


    }

    ====================================================

  5. #5
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Gurgaon,India
    Posts
    4,103

    Re: Move focus from one Text Editor to another Text Editor

    What to check? Are you trying to provide solution for the posted problem or are you posting the same problem & the posted code is not working..

  6. #6
    Registered User
    Join Date
    Jul 2011
    Posts
    13

    Re: Move focus from one Text Editor to another Text Editor

    Hi,

    I have provided solution in my last post. I have tested it correctly at my end.

    Can you please tell me what problem you are facing?

  7. #7
    Nokia Developer Moderator
    Join Date
    Mar 2003
    Location
    Lempäälä/Finland
    Posts
    29,179

    Re: Move focus from one Text Editor to another Text Editor

    Quote Originally Posted by nvaidy01 View Post
    Hi,

    I have provided solution in my last post. I have tested it correctly at my end.

    Can you please tell me what problem you are facing?
    basically you should identify in your post what the code is for, otherwise it is pretty hard to figure out what you want people to do with the code provided.

  8. #8
    Registered User
    Join Date
    Jul 2011
    Posts
    13

    Re: Move focus from one Text Editor to another Text Editor

    Sorry for inconvenience, let me explain the whole code.

    In ConstructL I have created two text-editor iEditor and iEditor1 and also have defined their attributes.

    ActivateL method is used to set text to editor.

    For switching focus from one text-editor to another text-editor two method has been used OfferKeyEventL and HandlePointerEventL.

    1) In OfferKeyEventL method based on selected key focus will change (by default iEditor will be in focus).

    If user clicks on RightArrow key then iEditor1 will be in focus and if user clicks on LeftArrow then iEditor will be in focus.

    2) In HandlePointerEventL method based on mouse click coordinates focus will change.

    HandlePointerEventL implementation is for emulator testing and OfferKeyEventL implementation is for on device testing and for non-touch devices.

Similar Threads

  1. Replies: 0
    Last Post: 2011-01-13, 05:32
  2. How to make text editor exactly like S60 default sms editor?
    By madsum in forum Symbian User Interface
    Replies: 9
    Last Post: 2009-11-10, 10:02
  3. rich text editor problem (switcing from text to numbers)
    By noam segal in forum Symbian User Interface
    Replies: 1
    Last Post: 2007-10-31, 15:01
  4. how to move from list box to text editor on dialog box
    By manjunaths in forum Symbian User Interface
    Replies: 0
    Last Post: 2006-12-07, 11:13
  5. Replies: 0
    Last Post: 2004-10-07, 08:57

Posting Permissions

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