×

Discussion Board

Results 1 to 11 of 11
  1. #1
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    switching between item controls on my form

    Hi,
    I have a form with Custom contros.
    When the App launches there's no focus on wither of the controls.
    In addition, when i use the arrow no item is gaining focus.

    now, i have read that i need to implement OfferKeyEventL function?
    Can you give me a link to a similar example?
    should i programatically set focus for the 1st item on startup or there's a property that can be set in the editor?

    I am using the UIDesigner.

    Thanks a lot for your replies.

  2. #2
    Registered User
    Join Date
    Feb 2007
    Location
    India
    Posts
    1,128

    Re: switching between item controls on my form

    Go through this link . Each control has SetFocus function.....

  3. #3
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    Hi,
    Sorry for misleading...
    1st of all, it's not a form but a container.
    i have an empty container which has some custom control on it and regular ones like check box, label etc.
    I need an example to switch between the controls with the arrows.
    I know about the SetFocus function, i just wonder how do i know to which control should i give focus or take the focus from when i hit the arrow? Should i check which control has the focus now? I'm sure thare's a clear method to that.
    Thanks a lot.

  4. #4
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    Ok, i have found an example that might help.
    those 2 added functions might do the job.
    I will try it later since i don't have my environment now, anybody tried it or have another advise?
    Thanks.

  5. #5
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    Ok, i have tried it but the App crash when it comes to:
    CCoeControlArray::TCursor cursor = Components().Begin();
    As far as i understand, i am not usin InitComponentArrayL but instead i use the default of the ui design which is CountComponentControls, ComponentControl.
    What seems to be the replaceble for that in MoveFocusUp/Down functions in order to get my app to be stable?

    Thanks.

  6. #6
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    I have spent some time reading some answers in this forum and i see some solutions to handling control's focus but it's easy with 2 controls.
    What might be the best solution for 'n' controls?

    Thanks.

  7. #7
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,025

    Re: switching between item controls on my form

    Well you can maintain an index, corresponding to each control. Just increment/decrement that index in OfferKeyEvent() , inside the EKeyUpArrow / EKeyDownArrow cases.Now according to the index, you can perform UI changes or else on Controls. For e.g. If the current focus is on editor, & on pressing down key the control needs to go on a label, then change the index to Elabel(for e.g.) & change color of label etc.

  8. #8
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    Thanks for your reply.
    Well there are indexes already created by the uidesign but i want it to be Automatically.
    When i press "up" i want it to go up to the control which is above.
    I can take it from the ENUM but i guess that i need to maintain it manually in case control location is changes...

    But this could be a good idea.

  9. #9
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    Hi,
    Now i handle the events correctly but i don't see any visibility in focus changes...
    i use custom check boxes and a label as i saw in some examples here...
    i have bitmap with masks.
    Why do you think this is happening?

    here's the code:
    On ConstructL:
    .
    .
    iFocusControl = ComponentControl(0);
    ComponentControl(0)->SetFocus(ETrue, EDrawNow); //focus on the 1st control
    .
    .

    On OfferKeyEventL:
    .
    .
    // [[[ begin generated region: do not modify [Generated Contents]

    // ]]] end generated region [Generated Contents]
    static TInt aIndex = 0;
    if (aType == EEventKey)
    {
    switch(aKeyEvent.iCode)
    {
    case EKeyDownArrow:
    if (iFocusControl == NULL)
    return EKeyWasNotConsumed;

    aIndex++;
    if (aIndex>ELastControl-1)
    aIndex = 0;

    iFocusControl = ComponentControl(aIndex);

    DrawDeferred();

    return EKeyWasConsumed;
    break;
    case EKeyUpArrow:
    if (iFocusControl == NULL)
    return EKeyWasNotConsumed;

    aIndex--;
    if (aIndex<0)
    aIndex = ELastControl-1;

    iFocusControl = ComponentControl(aIndex);

    DrawDeferred();

    return EKeyWasConsumed;
    break;
    case EKeyDevice3:
    break;
    }
    }

    if ( iFocusControl != NULL
    && iFocusControl->OfferKeyEventL( aKeyEvent, aType ) == EKeyWasConsumed )
    {
    return EKeyWasConsumed;
    }


    return CCoeControl::OfferKeyEventL( aKeyEvent, aType );
    .
    .
    This code is just for testing....
    Thanks.
    Last edited by Mrgoos; 2011-02-03 at 05:31.

  10. #10
    Nokia Developer Champion
    Join Date
    Jun 2008
    Location
    Noida,India
    Posts
    4,025

    Re: switching between item controls on my form

    well you need to put the code which would correspond to index changes in the controls.For e.g. if you have two controls, one is label & other is editor.Now if the focus is initially on editor & on pressing down the control goes to label , then you need to code accordingly.So in this case, Call the Editor's SetFocus(EFalse) & call label's member functions which would change its color(e.g OverridecolorL()).

    In case of bitmaps too you need to draw bitmap accordingly to the value of focus index..So in Draw() you can put conditional statements , as which bitmap to draw.

  11. #11
    Registered User
    Join Date
    Apr 2008
    Posts
    26

    Re: switching between item controls on my form

    It's strange because the example that i'm using doesn't call SetFocus(EFalse) etc though it make sence that it should...
    Well, i will check it again and post here.

    Thanks.

Similar Threads

  1. Which item on a form is selected
    By ksadil in forum Mobile Java General
    Replies: 2
    Last Post: 2010-06-14, 13:46
  2. Switching From on Form to another
    By apnasi in forum Mobile Java General
    Replies: 4
    Last Post: 2010-04-06, 10:59
  3. Switching between the controls (Urgent)
    By marvik_34 in forum Symbian
    Replies: 1
    Last Post: 2006-08-11, 22:46
  4. Switching between the controls (Urgent)
    By marvik_34 in forum Mobile Java General
    Replies: 1
    Last Post: 2006-08-11, 22:46

Posting Permissions

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