×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    May 2007
    Posts
    20

    focus change for controls in view

    Hi,

    I have the following code

    Code:
    if ( iNumEditor->IsFocused() )
    		{
    		if ( ((aKeyEvent.iCode == EKeyDownArrow) || (aKeyEvent.iCode == EKeyUpArrow)) && aType == EEventKey )
    			{
    			iNumEditor->SetFocus( EFalse );
    			iIMsgEditor->SetFocus( ETrue );			
    			iFocusControl = iIMsgEditor;
    			return EKeyWasConsumed;
    			}
    		else 
    			{
    			iFocusControl->OfferKeyEventL( aKeyEvent, aType );
    			}
    		}
    	if ( iIMsgEditor->IsFocused() ) 
    		{
    		if ( ((aKeyEvent.iCode == EKeyDownArrow) || (aKeyEvent.iCode == EKeyUpArrow)) && aType == EEventKey )
    			{
    			iIMsgEditor->SetFocus( EFalse );
    			iNumEditor->SetFocus( ETrue );
    			iFocusControl = iNumEditor; 
    			return EKeyWasConsumed;
    			}
    		else 
    			{
    			iFocusControl->OfferKeyEventL( aKeyEvent, aType );
    			}
    		}
    	
    		return EKeyWasNotConsumed;
    The problem with this code is that when i press the down arrow key for the first time the buttons(key events) on the text control(iMsgEditor) do not work. However on subsequent attempts it works fine. I fail to understand the fault in my own logic :(.

    Sorry for the long post. Would be glad if somebody helps me out. And Btw the point of the logic is to change the focus of the editors on arrow key up and down.

    Thanks,
    Eswar.

  2. #2
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: focus change for controls in view

    I am not really aware of how this editor controls work, however you can try what happens if you do not forward EKeyUp/DownArrow to the controls at all. In the current code the control which becomes focused on the first Up/DownArrow press, receives an EEventKeyUp without an EEventKeyDown, it might be surprising - since the EEventKeyDown was forwarded to the other control.

  3. #3
    Registered User
    Join Date
    May 2007
    Posts
    20

    Re: focus change for controls in view

    Yes i think the problem is bcoz of the key event to the unfocussed control. Culd u suggest a way out of this mess ? or culd someone suggest some alternate logic ?

  4. #4
    Nokia Developer Moderator
    Join Date
    Feb 2006
    Location
    Oslo, Norway
    Posts
    28,750

    Re: focus change for controls in view

    Ooops, you should try
    Code:
    if ( iNumEditor->IsFocused() )
    		{
    		if ( ((aKeyEvent.iCode == EKeyDownArrow) || (aKeyEvent.iCode == EKeyUpArrow)) && aType == EEventKey )
    			{
    			iNumEditor->SetFocus( EFalse );
    			iIMsgEditor->SetFocus( ETrue );			
    			iFocusControl = iIMsgEditor;
    			return EKeyWasConsumed;
    			}
    		else 
    			{
    			return iFocusControl->OfferKeyEventL( aKeyEvent, aType );
    			}
    		}
    	if ( iIMsgEditor->IsFocused() ) 
    		{
    		if ( ((aKeyEvent.iCode == EKeyDownArrow) || (aKeyEvent.iCode == EKeyUpArrow)) && aType == EEventKey )
    			{
    			iIMsgEditor->SetFocus( EFalse );
    			iNumEditor->SetFocus( ETrue );
    			iFocusControl = iNumEditor; 
    			return EKeyWasConsumed;
    			}
    		else 
    			{
    			return iFocusControl->OfferKeyEventL( aKeyEvent, aType );
    			}
    		}
    	
    		return EKeyWasNotConsumed;
    }
    first.

  5. #5
    Registered User
    Join Date
    May 2007
    Posts
    20

    Re: focus change for controls in view

    Thanks wizard. But its still not working :(.

  6. #6
    Regular Contributor
    Join Date
    Apr 2006
    Location
    India
    Posts
    383

    Re: focus change for controls in view

    Hi!
    Following code needed at the beginning of the offer key
    if(aType != EEventKey)
    {
    return EKeyWasNotConsumed;
    }
    If the key is not of type event key just return from it

    I hope u know.. when u press the key it generates 3 key codes (TEventCode)
    1.key down, 2.the actual key code n 3.key up.

    EEventKey:Key event.
    This is the event that is sent when a character has been received from the keyboard.
    If an EEventKey event is associated with an EEventKeyDown or EEventKeyUp event (typically EEventKeyDown), the EEventKey event occurs after the EEventKeyDown/EEventKeyUp event.In practice, the only keys potentially likely to have their EEventKey event generated on the up rather than the down are modifier keys.

    Hope it helps u
    Regards,
    Shilpa Kulkarni

  7. #7
    Registered User
    Join Date
    May 2007
    Posts
    20

    Re: focus change for controls in view

    Thanks shilpa .. but its still not working :( ..
    FYI :: if anybody is referring this thread pls note that there is a problem with the above code. I had to use another approach for this thing. If anybody by any chance can explain the above behavior it will be great, just for information purpose.

Similar Threads

  1. Where is the best to change view?
    By tqchcm in forum Symbian User Interface
    Replies: 4
    Last Post: 2007-09-19, 07:28
  2. Replies: 2
    Last Post: 2006-02-20, 02:00
  3. Change View
    By fdivita in forum Symbian
    Replies: 0
    Last Post: 2004-12-10, 13:22
  4. Change View
    By fdivita in forum Symbian User Interface
    Replies: 0
    Last Post: 2004-12-10, 10:46
  5. change focus
    By f_alonso_1 in forum Symbian
    Replies: 0
    Last Post: 2003-07-17, 13:34

Posting Permissions

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