October 31, 2025, 05:28:34 AM

News:

Own IWBasic 2.x ? -----> Get your free upgrade to 3.x now.........


Keyboard Input

Started by LarryMc, March 03, 2010, 02:16:01 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

LarryMc

In the designer I'm working on I'm using the arrow keys to move a control around.

I want to implement a coarse adjustment by using CTRL+ the arrow keys.

I haven't been able to figure out where and how to trap that.

?

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

fasecero

March 03, 2010, 06:31:50 PM #1 Last Edit: March 03, 2010, 06:34:42 PM by fasecero
Hi Larry, this work for me, I don't know if is the better approach  :)


DECLARE IMPORT, _GetAsyncKeyState ALIAS GetAsyncKeyState(vKey AS INT),WORD

DIALOG w1
OPENWINDOW w1,0,0,300,202,0x80C80080,0,"Caption",&w1_handler

run = 1
WAITUNTIL run=0

SUB w1_handler
SELECT @MESSAGE
CASE @IDKEYDOWN
ProcessKeyboard(@wparam)
CASE @IDCREATE
CENTERWINDOW w1
/* Initialize any controls here */
CASE @IDCLOSEWINDOW
run = 0
CLOSEDIALOG w1,@IDOK
ENDSELECT
RETURN
ENDSUB

SUB ProcessKeyboard(int nKey)
IF _GetAsyncKeyState(17)>0 THEN ' if control is pressed
if nKey = 37 THEN
DEBUGPRINT "left"
ENDIF
if nKey = 38 THEN
DEBUGPRINT "top"
ENDIF
if nKey = 39 THEN
DEBUGPRINT "right"
ENDIF
if nKey = 40 THEN
DEBUGPRINT "bottom"
ENDIF
ENDIF
ENDSUB

LarryMc

fasecero
Your code got me over the hump.

I modified it to do exactly what i wanted as follows:
SUB ProcessKeyboard(int nKey)
int cx=0,cy=0,adj=0
IF _GetAsyncKeyState(17)>0 THEN ' if control is pressed
adj=3
else
adj=0
endif
if nKey = 37 THEN
'DEBUGPRINT "left"
cx=-1-adj
ENDIF
if nKey = 38 THEN
'DEBUGPRINT "top"
cy=-1-adj
ENDIF
if nKey = 39 THEN
'DEBUGPRINT "right"
cx=1+adj
ENDIF
if nKey = 40 THEN
'DEBUGPRINT "bottom"
cy=1+adj
ENDIF
if cx or cy
MoveCtrls(cx,cy)
endif
ENDSUB


Thanks again

LarryMc
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library