Lazarus

Programming => Widgetset => GTK => Topic started by: Alextp on November 20, 2018, 06:17:05 pm

Title: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Alextp on November 20, 2018, 06:17:05 pm
I have test app which shows the gtk2 issue.
It shows pressed key in form caption

Code: Pascal  [Select]
  1. procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
  2. var
  3.   sh: TShortCut;
  4. begin
  5.   sh:= ShortCut(key, shift);
  6.   caption:= ShortCutToText(sh);
  7. end;
  8.  

Now user cannot press Shift+Home via his number block on notebook. (and 2nd keyboard too.)  He always gets Home instead of Shift+Home. He pressed Shift+Num7.

Code: Pascal  [Select]
  1. [~/Dev/CudaText_up]$ xev | grep keycode    
  2.     state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
  3.     state 0x11, keycode 79 (keysym 0xff95, KP_Home), same_screen YES,
  4.     state 0x11, keycode 79 (keysym 0xff95, KP_Home), same_screen YES,
  5.     state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
  6.     state 0x10, keycode 65 (keysym 0x20, space), same_screen YES,
  7.     state 0x10, keycode 65 (keysym 0x20, space), same_screen YES,
  8.     state 0x10, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,
  9.     state 0x11, keycode 110 (keysym 0xff50, Home), same_screen YES,
  10.     state 0x11, keycode 110 (keysym 0xff50, Home), same_screen YES,
  11.     state 0x11, keycode 50 (keysym 0xffe1, Shift_L), same_screen YES,

first 4 lines - he pressed Shift+Num7
next 2 lines -  spaces
next 4 lines - he presses Shift+<usual Home on 2nd keyboard>

(NumLock don't help, Home becomes 7)

Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: lucamar on November 20, 2018, 06:53:40 pm
That's the expected behaviour. The (Numpad) "7"  key will give "7" when unshifted and "Home" when shifted or viceversa, depending on the state of CapsLock. Idem with "1", "9" and "3" with "End", "PgUp" and "PgDn"

Although you're right in that OnKeyDown should pass Key=VK_Numpad7 and Shift = [ssShift].
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Blaazen on November 20, 2018, 07:12:09 pm
@ That's the expected behaviour.

No, it's Delphi incompatible.

Delphi 7:
Num Lock On:
Num7 (~103) / Shift+Home

Num Lock Off:
Home / Shift+Home

Lazarus + Qt4:
Num Lock On:
7 (~55) / Shift+Home

Num Lock Off:
Home / Shift+7 (~55)

EDIT: should be reported, incompatibility Delphi - Laz., and also GTk2-Qt4. BTW, you need LCLProc and Menus units to test Alextp's code.
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Alextp on November 20, 2018, 07:21:32 pm
User tells: in all other apps, he can do Shift+Home (using Num7 key); but he cannot in CudaText, CudaText only goes to line start (other apps do selection to line start)
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Alextp on November 20, 2018, 07:32:32 pm
Reported to https://bugs.freepascal.org/view.php?id=34576
pls comment there about Delphi7.
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: lucamar on November 20, 2018, 07:56:38 pm
@ That's the expected behaviour.

No, it's Delphi incompatible.

I meant the expected behaviour referred to how the keyboard works. I must confess that I've never tried this in code (one tends to assume there's a handy "Home" key somewhere :-[)  so I don't really know how Delphi (or FPC) copes with it. Some quick tests in this laptop--Dell D620--show some queerness but that may as well be because the keyboard itself is somewhat "queer"--at least compared to a normal desktop one.
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Martin_fr on November 20, 2018, 08:09:01 pm
Just tested, in gedit "num7" acting as "home" (numlock off) can not be used with shift to get shift-home. It will instead insert "7" into the text. With numlock, it is always "7".
Fedora 28
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Blaazen on November 20, 2018, 08:10:41 pm
My tests was also with laptop keyboard. Yes, it's better to have real Home/End keys.
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Blaazen on November 20, 2018, 08:15:21 pm
So I tested Kate:
NumLock Off: Home / Shift+Home
NumLock On: 7 / Home

It seems there are no two widgetsets and applicarions with the same behaviour. :)
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: zeljko on November 22, 2018, 02:56:58 pm
Does Qt/Qt5 works same as Kate ?
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: Blaazen on November 22, 2018, 05:06:09 pm
No.

Lazarus + Qt4 or Qt5 (same):
Num Lock Off: Home / Shift+7 (~55)
Num Lock On: 7 (~55) / Shift+Home

Kate:
NumLock Off: Home / Shift+Home
NumLock On: 7 / Home
Title: Re: Shift+Num7 must give Shift+Home, but gives only Home
Post by: zeljko on November 22, 2018, 07:57:13 pm
So ws implementation is probably wrong