×

Discussion Board

Results 1 to 10 of 10
  1. #1
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Unhappy Setfocus when user pressed up/down arrow keys (6600)

    hi,

    I have 3 controls (2 text Controls and one Command Button) Now when user press up or down key i want to set the focus to appropriate controls. How to do that ?

  2. #2
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Setfocus when user pressed up/down arrow keys (6600)

    you could use SetFocus() to set the focus to a control.
    i would ask you to use it in OfferKeyEventL().and also you can check whether the control is already focused using IsFocused() of CCoeControl class.

    Priju

  3. #3
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Smile Re: Setfocus when user pressed up/down arrow keys (6600)

    U r right,

    But if user pres up key, i want to set focus to the previous control and if user press down key, i want to set focus the the next control. How to do that ?
    Any sample code ?

  4. #4
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Setfocus when user pressed up/down arrow keys (6600)

    you need to have a work around in offerkeyeventL().
    it would be someting like this.(assuming you have got 3 controls, c1,c2,c3)
    if(UpKey && C2->IsFocused())
    {
    c2->SetFocus(EFalse);
    c1->SetFocus(ETrue);
    }
    if(DownKey && c2->IsFocused())
    {
    c2->SetFocus(EFalse);
    c3->SetFocus(ETrue);
    }

    i dont have a sample code now.it would be nice if you could search the forum.

    Priju

  5. #5
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Setfocus when user pressed up/down arrow keys (6600)

    something like this..
    i have not tested it,just a sample for you :))
    Say you have a Edwin,ListBox and Grid.

    Code:
    TKeyResponse CSampleContainer::OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType )
        {
             
       if ( iEdwin )
            {
            	
                if(  aKeyEvent.iCode == EKeyUpArrow  )
                    {
                    iEdwin->SetFocus( EFalse );
                    iListBox->SetFocus( ETrue );
                    return EKeyWasNotConsumed;
                    }
                if(  aKeyEvent.iCode == EKeyDownArrow  )
                    {
                    iEdwin->SetFocus( EFalse );
                    iGrid->SetFocus( ETrue );
                    return EKeyWasNotConsumed;
                    }
                
            return iEdwin->OfferKeyEventL( aKeyEvent, aType );
          }
          //..........
         // handle the same for other controls.
    
    }
    Priju

  6. #6
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Re: Setfocus when user pressed up/down arrow keys (6600)

    Hi,
    I m going to implement the same code. But i m not able to locate OfferKeyEventL.

  7. #7
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Setfocus when user pressed up/down arrow keys (6600)

    Quote Originally Posted by patilmmilind
    Hi,
    I m going to implement the same code. But i m not able to locate OfferKeyEventL.
    if you dont find one in your container add one for yourself in the header file and give proper implementation.
    this is the declaration
    Code:
    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
                                                 TEventCode aType );
    check the sdk for more details and go through a sample application to understand better.

    Priju

  8. #8
    Registered User
    Join Date
    Sep 2006
    Posts
    26

    Re: Setfocus when user pressed up/down arrow keys (6600)

    hi,
    check my code here.
    im using 3 labels n by pressing up n down arrows focus is changing here.

    for(TInt k=0;k<3;k++)
    {

    if(iLabel[k]->IsDimmed())
    {

    if(aKeyEvent.iCode == EKeyDownArrow )
    {


    iLabel[k]->SetDimmed(EFalse) ;
    if(k<2)
    {
    iLabel[k+1]->SetDimmed(ETrue);
    return EKeyWasNotConsumed;
    }

    else
    {
    k = 0;
    iLabel[0]->SetDimmed(ETrue);
    return EKeyWasNotConsumed;

    }
    }

    else if(aKeyEvent.iCode == EKeyUpArrow )
    {
    if(k==0)
    {
    iLabel[0]->SetDimmed(EFalse);
    iLabel[2]->SetDimmed(ETrue);
    return EKeyWasNotConsumed;
    }
    else
    {
    iLabel[k]->SetDimmed(EFalse);
    iLabel[k-1]->SetDimmed(ETrue);
    return EKeyWasNotConsumed;

    }


    }

    else if(aKeyEvent.iCode == EKeyDevice3 )
    {


    switch(k)
    {

    //by using up n down arrows focus is changed.so by pressing da select key implement ur own functionality here//

    }

    return EKeyWasNotConsumed
    }

    all da best,
    rees

  9. #9
    Registered User
    Join Date
    Nov 2006
    Posts
    5

    Re: Setfocus when user pressed up/down arrow keys (6600)

    Hi rees

    Thanks for the suggestion. I removed CEikEdwin from my code, Now i am using Bordered Edwin Control. Now i m not able to type anything in to that control. I am wondering why it is happening so ?

  10. #10
    Super Contributor
    Join Date
    Oct 2005
    Location
    Hyderabad,India
    Posts
    1,156

    Re: Setfocus when user pressed up/down arrow keys (6600)

    Quote Originally Posted by patilmmilind
    Now i m not able to type anything in to that control. I am wondering why it is happening so ?
    have u implemented OfferKeyEventL() for the edwin control ?
    Code:
    return iEdwin->OfferKeyEventL( aKeyEvent, aType );
    Priju

Similar Threads

  1. arrow keys for UP & DOWN navigation
    By tenren in forum Mobile Java General
    Replies: 1
    Last Post: 2006-07-19, 11:56
  2. My soft Keys of Nokia 6600 are not working for my application
    By ummarbhutta in forum Mobile Java General
    Replies: 6
    Last Post: 2006-03-27, 22:16
  3. Replies: 2
    Last Post: 2004-09-15, 22:47
  4. how to catch two keys pressed simultaneously?
    By knesek in forum Mobile Java General
    Replies: 5
    Last Post: 2002-08-23, 10:25
  5. arrow keys
    By Nokia_Archive in forum PersonalJava
    Replies: 1
    Last Post: 2002-05-24, 17:42

Posting Permissions

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