Assign a button control to arrow key
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Assign a button control to arrow key
Hi Everybody,
Is there a way to assign the function of a button to an arrow key so when the user uses the left or right arrow key it functions as if they clicked a button?
Thanks,
Jeff
Is there a way to assign the function of a button to an arrow key so when the user uses the left or right arrow key it functions as if they clicked a button?
Thanks,
Jeff
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
Sorry, I guess I should have mentioned that.
It's a Window.
I've tried:
SETKEY( K_UP, { || MsgInfo( "UP pressed" ) } )
SETKEY( K_DOWN, { || MsgInfo( "DOWN pressed" ) } )
SETKEY( K_LEFT, { || MsgInfo( "LEFT pressed" ) } )
SETKEY( K_RIGHT, { || MsgInfo( "RIGHT pressed" ) } )
But with no luck ... basically nothing happens. (inkey.ch is in my code)
Jeff
It's a Window.
I've tried:
SETKEY( K_UP, { || MsgInfo( "UP pressed" ) } )
SETKEY( K_DOWN, { || MsgInfo( "DOWN pressed" ) } )
SETKEY( K_LEFT, { || MsgInfo( "LEFT pressed" ) } )
SETKEY( K_RIGHT, { || MsgInfo( "RIGHT pressed" ) } )
But with no luck ... basically nothing happens. (inkey.ch is in my code)
Jeff
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
Jeff,
When a window or a dialogbox has several controls, one of them has the focus. So you should assign bKeyDown or bKeyChar to all of them:
oBtn1:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn2:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn3:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn4:bKeyChar = { | nKey | MsgInfo( nKey ) }
Instead of MsgInfo(), call a function where you check nKey and act accordingly
When a window or a dialogbox has several controls, one of them has the focus. So you should assign bKeyDown or bKeyChar to all of them:
oBtn1:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn2:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn3:bKeyChar = { | nKey | MsgInfo( nKey ) }
oBtn4:bKeyChar = { | nKey | MsgInfo( nKey ) }
Instead of MsgInfo(), call a function where you check nKey and act accordingly
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact:
- Antonio Linares
- Site Admin
- Posts: 37481
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Contact:
- Jeff Barnes
- Posts: 912
- Joined: Sun Oct 09, 2005 1:05 pm
- Location: Ontario, Canada
- Contact: