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 578d026520
commit 2f8bee262c
3 changed files with 8 additions and 0 deletions

View File

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

View File

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

View File

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