Skip navigation.
Home
The QNX Community Portal

View topic - Handle arrow key press

Handle arrow key press

Isn't the name clear?

Handle arrow key press

Postby coder22 » Wed Jul 21, 2010 9:34 pm

i need to handle arrow key presses .
I am not sure about what callback to use.

Pt_CB_HotKey??

Pt_CB_RAW??

Can any one tell with a small example
coder22
New Member
 
Posts: 6
Joined: Mon Jul 19, 2010 5:51 pm

RE: Handle arrow key press

Postby coder22 » Thu Jul 22, 2010 12:26 am

Though i figured out to use Pt_CB_RAW

I try to restrict the key press to the down arrow key... I just need to take an action only when the down arrow key are pressed.

here is some code



int keycheck( PtWidget_t *pwgt, void *pvData, PtCallbackInfo_t *ptsInfo )

{


PhEvent_t *event = ptsInfo ? ptsInfo->event : NULL;
PhKeyEvent_t *keyevent = event ? (PhKeyEvent_t *)PhGetData(event):NULL;

//this handles all key presses.... set it only for down

if(event && (event->type & Ph_EV_KEY) && (keyevent->key_cap & Pk_Down))
printf("\n down key press");


return ( Pt_CONTINUE );
}

But when i run this code. this code prints the value on all key presses. I want to restrict the print only when down key is pressed.

Thanks
coder22
New Member
 
Posts: 6
Joined: Mon Jul 19, 2010 5:51 pm

RE: Handle arrow key press

Postby qnxloader » Thu Jul 22, 2010 12:08 pm

PhKeyEvent_t *key_ev;
key_ev = (PhKeyEvent_t *)PhGetData( cbinfo->event );

if (key_ev->key_flags & Pk_KF_Cap_Valid)
switch ( key_ev->key_cap )
{
// --------- UP ARROW -----------
case 0xF052:
if ( key_ev->key_flags & (Pk_KF_Key_Down | Pk_KF_Key_Repeat))
{
// KEY press and repeat
}
else
if ( (key_ev->key_flags & 0x0F)== 0)
{
// key unpress
}
break;
}
qnxloader
Senior Member
 
Posts: 206
Joined: Mon Oct 06, 2003 8:29 am

RE: Handle arrow key press

Postby coder22 » Fri Jul 30, 2010 8:56 pm

Hi
Now i just want to handle the printable keys.
I want to take just one action whenever any of the printable keys are pressed.
Is there a way to do it?
or will have to switch case for all possible cases.

Thanks
coder22
New Member
 
Posts: 6
Joined: Mon Jul 19, 2010 5:51 pm


Return to GUI Programming

Who is online

Users browsing this forum: No registered users and 2 guests