PDA

View Full Version : keyboard commands



eFFeFFe
10-16-2007, 07:19 AM
Hi ... Is it possible to capture key inputs and assign them to a function in an lscript ? For instance, use the left and right arrows to cycle thru the options in a choise control box (ctlchoice) ?

grtzz,
eF.

adamredwoods
10-16-2007, 02:55 PM
Yes.



reqkeyboard
A new callback named reqkeyboard() can be defined to intercept keyboard activity on the active Requester panel. This function takes a single argument which represents the raw key pressed. It should return a Boolean false or true value indicating that the key should or should not be further processed by the system, respectively.

@version 2.6
@warnings
@script generic

generic
{
reqbegin("Testing reqkeyboard()");

c1 = ctlstring("String","value");

if(reqpost())
info("You pressed Ok");
else
info("You pressed Cancel");

reqend();
}

reqkeyboard: key
{
if(key == 13) // enter
{
reqabort(true);
return(true);
}
else if(key == 27) // escape
{
reqabort();
return(true);
}

return(false);
}

The following pre-defined constants have been added to the environment in order to help process key events:
REQKB_F1 REQKB_KB0 REQKB_KP0
REQKB_F2 REQKB_KB1 REQKB_KP1
REQKB_F3 REQKB_KB2 REQKB_KP2
REQKB_F4 REQKB_KB3 REQKB_KP3
REQKB_F5 REQKB_KB4 REQKB_KP4
REQKB_F6 REQKB_KB5 REQKB_KP5
REQKB_F7 REQKB_KB6 REQKB_KP6
REQKB_F8 REQKB_KB7 REQKB_KP7
REQKB_F9 REQKB_KB8 REQKB_KP8
REQKB_F10 REQKB_KB9 REQKB_KP9
REQKB_F11
REQKB_F12 REQKB_ALT REQKB_RETURN
REQKB_SHIFT REQKB_INSERT
REQKB_LEFT REQKB_CTRL REQKB_HOME
REQKB_RIGHT REQKB_END
REQKB_UP REQKB_DELETE REQKB_PAGEUP
REQKB_DOWN REQKB_HELP REQKB_PAGEDOWN

eFFeFFe
10-17-2007, 03:28 AM
Hi Adam ... tnx for the example !!! ... it's what i'm looking for ... is this already in the latest reference and user guide of lscript ?

grtz,
eF,