Lazarus

Programming => Widgetset => Cocoa => Topic started by: scribly on March 31, 2020, 10:32:25 am

Title: Global hotkey
Post by: scribly on March 31, 2020, 10:32:25 am
I'd like to register a hotkey (e.g cmd+alt+Q)" that will do a specific action in my application when pressed, even when my app isn't in the foreground.
Is that possible? I checked out getKeyState but that only gets modifiers
Title: Re: Global hotkey
Post by: trev on March 31, 2020, 12:29:56 pm
This Apple documentation (https://developer.apple.com/library/archive/documentation/Cocoa/Conceptual/EventOverview/HandlingKeyEvents/HandlingKeyEvents.html#//apple_ref/doc/uid/10000060i-CH7-SW1) may be of help.
Title: Re: Global hotkey
Post by: scribly on March 31, 2020, 11:49:13 pm
I managed to get it to work with Install(Application)EventHandler, and RegisterEventHotkey
Title: Re: Global hotkey
Post by: trev on April 01, 2020, 02:17:08 am
I may be wrong, but isn't RegisterEventHotkey from the 32 bit Carbon framework? In which case it will not work after Mojave...
Title: Re: Global hotkey
Post by: scribly on April 01, 2020, 09:01:24 am
I'm on catalina and it still works. It's one of the functions that they kept functional in 64-bit
Title: Re: Global hotkey
Post by: trev on April 01, 2020, 12:47:45 pm
Good to know.
TinyPortal © 2005-2018