Recent

Author Topic: Accelerator Characters  (Read 437 times)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2518
    • havefunsoft.com
Accelerator Characters
« on: September 08, 2020, 10:14:23 pm »
There a couple of items that have been created recently to bring up the inconsistency in Accelerator characters across multiple platforms:
https://bugs.freepascal.org/view.php?id=37719
https://bugs.freepascal.org/view.php?id=37721

In macOS (actually even with MacOSX) the Accelerator keys has been known as "mnemonics".
But starting with 10.7 those have been deprecated from the system user interface entirely

NSCell.menomic, NSMenu.mnemonic
Quote
Returns the character in the receiver’s title that appears underlined for use as a mnemonic.

macOS human user interface guidelines suggest to use Menu shortcuts instead.

Neither Carbon nor Cocoa supports "&" notation. instead they just ignore them.
Yet, LCL itself does support "&" internally, which produces a partial support, where some accelerations do work, others do not work at all.

I'd say that there should not be any "&" support for Cocoa, thus LCL needs to be updated to avoid processing DialogChar() method. DialogChar() is LCL level implementation of accelerator keys.

Code: Diff  [Select][+][-]
  1. Index: lcl/include/interfacebase.inc
  2. ===================================================================
  3. --- lcl/include/interfacebase.inc       (revision 63694)
  4. +++ lcl/include/interfacebase.inc       (working copy)
  5. @@ -91,7 +91,8 @@
  6.      lcReceivesLMClearCutCopyPasteReliably,
  7.      lcSendsUTF8KeyPress,
  8.      lcEmulatedMDI,
  9. -    lcNativeTaskDialog: Result := LCL_CAPABILITY_YES;
  10. +    lcNativeTaskDialog,
  11. +    lcAccelleratorKeys: Result := LCL_CAPABILITY_YES;
  12.    else
  13.      Result := LCL_CAPABILITY_NO;
  14.    end;
  15. Index: lcl/include/wincontrol.inc
  16. ===================================================================
  17. --- lcl/include/wincontrol.inc  (revision 63694)
  18. +++ lcl/include/wincontrol.inc  (working copy)
  19. @@ -5948,6 +5948,7 @@
  20.    ParentForm: TCustomForm;
  21.  begin
  22.    Result := False;
  23. +  if WidgetSet.GetLCLCapability(lcAccelleratorKeys) = LCL_CAPABILITY_NO then Exit;
  24.    ParentForm := GetParentForm(Self);
  25.    if ParentForm <> nil then
  26.    begin
  27. Index: lcl/interfacebase.pp
  28. ===================================================================
  29. --- lcl/interfacebase.pp        (revision 63694)
  30. +++ lcl/interfacebase.pp        (working copy)
  31. @@ -72,7 +72,8 @@
  32.      lcTransparentWindow,        // ability to pass mouse messages through a window (on win32 LM_NCHITTEST with HTTRANSPARENT result)
  33.      lcTextHint,                 // native TextHint support
  34.      lcNativeTaskDialog,         // task dialog under mswindows for widgetsets different than win32/wince. Used in LCLTaskDialog. eg Qt/Qt5 must set this option to false otherwise taskdialog segfaults.
  35. -    lcCanDrawHidden             // the system rendering engine might request a hidden control to be drawn (macOS 10.9 and later)
  36. +    lcCanDrawHidden,            // the system rendering engine might request a hidden control to be drawn (macOS 10.9 and later)
  37. +    lcAccelleratorKeys          // the system supports UI concept of &-like notation
  38.    );
  39.  
  40.    { TDialogButton }
  41. Index: lcl/interfaces/cocoa/cocoaobject.inc
  42. ===================================================================
  43. --- lcl/interfaces/cocoa/cocoaobject.inc        (revision 63694)
  44. +++ lcl/interfaces/cocoa/cocoaobject.inc        (working copy)
  45. @@ -295,6 +295,8 @@
  46.      lcTransparentWindow,
  47.      lcCanDrawHidden:
  48.        Result := LCL_CAPABILITY_YES;
  49. +    lcAccelleratorKeys:
  50. +      Result := LCL_CAPABILITY_NO;
  51.    else
  52.      Result := inherited;
  53.    end;
  54.  
« Last Edit: September 08, 2020, 10:23:30 pm by skalogryz »
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

Alextp

  • Hero Member
  • *****
  • Posts: 1145
    • UVviewsoft
Re: Accelerator Characters
« Reply #1 on: September 08, 2020, 10:32:43 pm »
I support removing this from cocoa. Alt+letter gives some unicode chars in Edit. by macOS.

VTwin

  • Hero Member
  • *****
  • Posts: 936
  • Former Turbo Pascal 3 user
Re: Accelerator Characters
« Reply #2 on: September 10, 2020, 01:28:19 am »
If I understand correctly, I agree. Accelerator keys are are not supported on Mac, and should be ignored.

While I sometimes wish Mac did support accelerator keys, it is not part of their user interface guidelines.
“Talk is cheap. Show me the code.” -Linus Torvalds

Free Pascal Compiler 3.2.0
macOS 10.13.6: Lazarus 2.0.10 (64 bit Cocoa)
Ubuntu 18.04.3: Lazarus 2.0.10 (64 bit on VBox)
Windows 7 Pro SP1: Lazarus 2.0.10 (64 bit on VBox)

skalogryz

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 2518
    • havefunsoft.com
Re: Accelerator Characters
« Reply #3 on: September 10, 2020, 02:39:05 am »
They're not supported natively by macOS, yet they can be emulated!
Since they're part of LCL UI logic.

Maybe it's worth breaking macOS rules and guidelines in order to achieve cross-platform solutions?!
(the screenshot is made in MacOSX 10.6)
Patron Cocoa Widgetset development https://www.patreon.com/skalogryz

trev

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1000
  • Former Delphi 1-7, 10.2 User
Re: Accelerator Characters
« Reply #4 on: September 10, 2020, 08:01:26 am »
One of Lazarus' features:

Quote
Lazarus form designer uses LCL (Lazarus Component Library) which is especially designed for cross platform usage. Building your project for different platforms will give you native look and feel on each platform. There are no changes to the project needed.

I would remove the & accelerator keys from Cocoa.
o Lazarus v2.1.0 r63871, FPC v3.3.1 r46876, macOS 10.14.6 (with sup update), Xcode 11.3.1
o Lazarus v2.1.0 r61574, FPC v3.3.1 r42318, FreeBSD 12.1 amd64 (VMware Fusion VM)
o FPC 3.0.4, FreeBSD 12.2-STABLE r365646 amd64
o Lazarus v2.1.0 r61574, FPC v3.0.4, Ubuntu 18.04 (Parallels VM)

 

TinyPortal © 2005-2018