Author Topic: Binding numpad keys for selection  (Read 3889 times)

yurakolotov

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Binding numpad keys for selection
« on: April 22, 2018, 05:05:31 PM »
Hi,
This is my first time here, so apologies in advance if I inadvertently break some rules or conventions...

When I upgraded from SlickEdit 2011 (v. 16.0.0.02 32 bit) to SlickEdit 2013 (v. 18.0.1.2 64 bit), I have lost the ability to use my numpad arrows in the same manner as regular arrows.

I am used to working without NumLock, and to selecting (for example) "from here to end of line" by pressing Shift+End on NumPad, or "from here to next word" by "Shift+Right". But in this version this binding does not work, UNLESS NumPad is on.

I thought I could just bind these keys one by one, but when I search for biding on Shift+End (using regular End) or Shift+Right, all I get is a list of some 20 "cua-select" commands, without specification of which does what.

Is there some place else I must look?

Thanks!


Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Binding numpad keys for selection
« Reply #1 on: April 23, 2018, 10:20:38 AM »
All the shift key combinations bind to cua_select and the cua_select macro figures out which specific key combination was pressed.  If you want to look at the code for cua_select (all 492 lines of it), type fp cua_select on the slick command line.

In the key bindings dialog you can see what keycode gets generated for different keys.  In V22 I get this
With numlock off, the end key gives end,  shift end gives shift end.
With numlock on, the end/1 key gives Pad1, shift end/1 gives end.
What do you get for this?

yurakolotov

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: Binding numpad keys for selection
« Reply #2 on: April 23, 2018, 03:37:21 PM »
All the shift key combinations bind to cua_select and the cua_select macro figures out which specific key combination was pressed.  If you want to look at the code for cua_select (all 492 lines of it), type fp cua_select on the slick command line.

In the key bindings dialog you can see what keycode gets generated for different keys.  In V22 I get this
With numlock off, the end key gives end,  shift end gives shift end.
With numlock on, the end/1 key gives Pad1, shift end/1 gives end.
What do you get for this?

Regular (not numpad) end key gives End, shift end gives Shift-End.
With numlock off, the numpad end key gives End, shift end gives Shift+Pad1.
With numlock on, the numpad end key gives Pad1, shift end gives Shift-End.

(Oh, and the "Shift-End" shows a long list of cua_select, undifferentiated to specific shift+end command. I would attach a printscreen if I knew how...)

So I think the problem is that I get Shift+Pad1 instead of Shift+End for Shift-numpad-end with numlock off.
« Last Edit: April 23, 2018, 03:39:58 PM by yurakolotov »

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Binding numpad keys for selection
« Reply #3 on: April 24, 2018, 11:59:53 AM »
You could try binding Shift+Pad1 to this macro.  I'm not sure if this is the best way to do it.  I tried using call_key instead of call_event but I couldn't get it to work.

Code: [Select]
_command void my_shift_end() name_info(',')
{
   call_event(p_window_id, s_end);
}

or alternatively, record a macro and press shift+end - then bind to shift+pad1

Code: [Select]
_command last_recorded_macro() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   _macro('R',1);
   deselect();
   _select_char('','E');
   end_line();
   select_it("CHAR",'','E');
}
« Last Edit: April 24, 2018, 12:04:55 PM by Graeme »

Clark

  • SlickEdit Team Member
  • Senior Community Member
  • *
  • Posts: 6866
  • Hero Points: 528
Re: Binding numpad keys for selection
« Reply #4 on: April 24, 2018, 05:55:33 PM »
What OS are you running?

jporkkahtc

  • Senior Community Member
  • Posts: 2620
  • Hero Points: 210
  • Text
Re: Binding numpad keys for selection
« Reply #5 on: April 25, 2018, 08:44:11 PM »
On Windows 10, I get different results, that also seem wrong.
With numlock off, the numpad end key gives End, shift end gives Shift+End.
With numlock on, the numpad end key gives Pad1, shift end gives End.

For comparison: AutoHotKey on Windows can detect the difference
With numlock off, the numpad end key PadEnd and ShiftPadEnd
With numlock on, the numpad end key gives Pad1 and PadEnd.
AHK cannot distinguish between NumLock+Shift+Pad1 and NoNumLock Pad1: Both produce PadEnd.


yurakolotov

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: Binding numpad keys for selection
« Reply #6 on: April 26, 2018, 02:32:49 PM »
What OS are you running?

On Windows 10, I get different results, that also seem wrong.
With numlock off, the numpad end key gives End, shift end gives Shift+End.
With numlock on, the numpad end key gives Pad1, shift end gives End.

For comparison: AutoHotKey on Windows can detect the difference
With numlock off, the numpad end key PadEnd and ShiftPadEnd
With numlock on, the numpad end key gives Pad1 and PadEnd.
AHK cannot distinguish between NumLock+Shift+Pad1 and NoNumLock Pad1: Both produce PadEnd.

Fedora 20, I think...
But pretty sure same problem was on an oldish Ubuntu.

I know for sure that on Fedora 12 it worked fine.
« Last Edit: April 26, 2018, 02:35:12 PM by yurakolotov »

yurakolotov

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: Binding numpad keys for selection
« Reply #7 on: April 26, 2018, 02:34:07 PM »
You could try binding Shift+Pad1 to this macro.  I'm not sure if this is the best way to do it.  I tried using call_key instead of call_event but I couldn't get it to work.

Code: [Select]
_command void my_shift_end() name_info(',')
{
   call_event(p_window_id, s_end);
}

or alternatively, record a macro and press shift+end - then bind to shift+pad1

Code: [Select]
_command last_recorded_macro() name_info(','VSARG2_MARK|VSARG2_REQUIRES_EDITORCTL)
{
   _macro('R',1);
   deselect();
   _select_char('','E');
   end_line();
   select_it("CHAR",'','E');
}

Ah... not really at home with recording/binding macros in SE. Could you point me to a guide on that? Right now I wouldn't know where to start...

Graeme

  • Senior Community Member
  • Posts: 2796
  • Hero Points: 347
Re: Binding numpad keys for selection
« Reply #8 on: April 27, 2018, 07:16:20 AM »
There's a brief demo video here
https://www.youtube.com/watch?v=n3kVkgSN9nk&feature=share

In the slick help file, look in the index for recorded macros.
So, start recording, press shift end, stop recording, enter a name for the macro (e.g. my_shift_end) and bind a key to it.  In Tools -> options -> keyboard -> key bindings  - type the name of the command in the "search by command" edit box, then select it in the list (i..e click on it), then click the add button at bottom right.  The "bind key" dialog will come up  - press Shift PadEnd (with numlock off) and click ok.

yurakolotov

  • Junior Community Member
  • Posts: 6
  • Hero Points: 0
Re: Binding numpad keys for selection
« Reply #9 on: April 30, 2018, 08:16:32 AM »
There's a brief demo video here
https://www.youtube.com/watch?v=n3kVkgSN9nk&feature=share

In the slick help file, look in the index for recorded macros.
So, start recording, press shift end, stop recording, enter a name for the macro (e.g. my_shift_end) and bind a key to it.  In Tools -> options -> keyboard -> key bindings  - type the name of the command in the "search by command" edit box, then select it in the list (i..e click on it), then click the add button at bottom right.  The "bind key" dialog will come up  - press Shift PadEnd (with numlock off) and click ok.

Great, this works. Thanks.

Unless anyone comes up with a more general solution (for auto-equating numpad keys with non-numpad keys), I'd say the issue is resolved.