SlickEdit Community
SlickEdit Product Discussion => SlickEditĀ® => Slick-CĀ® Macro Programming => Topic started by: jporkkahtc on August 02, 2018, 05:26:47 PM
-
Is it possible to bind to key up events?
Specifically, I want to do something while a key is pressed.
I have a key bound to toggle the vertical line for the right margin.
I had an idea: While that key is pressed make the vertical line visible at the current cursor position - allowing me to quickly check vertical alignment over a long span on lines.
I could still do this as a toggle, but I thought it would be neat to have it while the key is pressed.
I suppose I could also map it to while scroll-lock is on (but that interferes with excel).
-
You could make a command like this maybe and break out when you get a key besides the one you want.
_command void test_get_event() name_info(',')
{
for (i:=0;i<1000;++i) {
event = get_event();
eventName := event2name(event);
if (eventName!="F12") break;
say('test_get_event got F12');
}
}
I guess you would probably want to make it an infinite loop, I just made it to 1000 so I was sure I could get out of it ;)
-
Thanks.
Does SlickC have a sleep() function?
Or, instead of looping 1000 times, loop until elapsed time is > 2 seconds?
Oh! SlickC does have timer callbacks right? So I could set a timer callback to clear the vertical line after a couple of seconds.
For now I decided to just use a simple toggle.
The only problem with the code below is that sometimes the vertical line also appears in search results. Not always, but often.
Why would that be?
_command void set_col() name_info(','VSARG2_READ_ONLY|VSARG2_REQUIRES_MDI_EDITORCTL)
{
_str result = _default_option('R');
if (result == "0") {
_default_option('R', p_col-1);
} else {
_default_option('R', "0");
}
}
-
Look at the help on delay().