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 ?
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 ?
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
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 ?
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
something like this..
i have not tested it,just a sample for you :))
Say you have a Edwin,ListBox and Grid.
PrijuCode: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. }
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.Originally Posted by patilmmilind
this is the declaration
check the sdk for more details and go through a sample application to understand better.Code:TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
Priju
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
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 ?
have u implemented OfferKeyEventL() for the edwin control ?Originally Posted by patilmmilind
PrijuCode:return iEdwin->OfferKeyEventL( aKeyEvent, aType );