Cocoa: add callback for application specific Extended keys and non-US keyboards handling.

This commit is contained in:
David Jenkins 2025-01-28 12:08:46 +00:00 committed by rich2014
parent 831da47900
commit 4d285f21a0
3 changed files with 8 additions and 0 deletions

View File

@ -39,6 +39,8 @@ var
highestHandler: nil; highestHandler: nil;
// Event to call when there is no MainForm with MainForm.close // Event to call when there is no MainForm with MainForm.close
onQuitApp: nil; onQuitApp: nil;
// Platform key Event modification function
keyEventToVK: nil;
); );
); );

View File

@ -148,10 +148,13 @@ type
TCocoaApplicationEventHandler = function( event: NSEvent ): Boolean of object; TCocoaApplicationEventHandler = function( event: NSEvent ): Boolean of object;
// Need to pass to QueueAsyncCall which takes TDataEvent // Need to pass to QueueAsyncCall which takes TDataEvent
TCocoaApplicationOnAppQuitEvent = TDataEvent; TCocoaApplicationOnAppQuitEvent = TDataEvent;
// Platform specific NSEvent key translation to VK Keycode function
TCocoaApplicationEventToVK = function(AEvent: NSEvent): Word;
TCocoaConfigApplicationEvents = record TCocoaConfigApplicationEvents = record
highestHandler: TCocoaApplicationEventHandler; highestHandler: TCocoaApplicationEventHandler;
onQuitApp: TCocoaApplicationOnAppQuitEvent; onQuitApp: TCocoaApplicationOnAppQuitEvent;
keyEventToVK: TCocoaApplicationEventToVK;
end; end;
TCocoaConfigApplication = record TCocoaConfigApplication = record

View File

@ -595,6 +595,9 @@ begin
else else
VKKeyCode := MacCodeToVK(KeyCode); VKKeyCode := MacCodeToVK(KeyCode);
if Assigned(CocoaConfigApplication.events.keyEventToVK) then
VKKeyCode := CocoaConfigApplication.events.keyEventToVK(Event);
case VKKeyCode of case VKKeyCode of
// for sure, these are "non-printable" keys (see http://wiki.lazarus.freepascal.org/LCL_Key_Handling) // for sure, these are "non-printable" keys (see http://wiki.lazarus.freepascal.org/LCL_Key_Handling)
VK_F1..VK_F24, // Function keys (F1-F12) VK_F1..VK_F24, // Function keys (F1-F12)