Recent

Author Topic: Global hotkey component  (Read 1062 times)

regs

  • Jr. Member
  • **
  • Posts: 77
Global hotkey component
« on: March 09, 2025, 12:09:38 am »
I made a cross platform global hotkey component. For Windows, Unix X11 and macOS Cocoa/Carbon. macOS one using part of Carbon API, which is still legit. And as there is no global hotkey API for Cocoa yet. For Cocoa LCLWidgetType should be explicitly set to Cocoa.

It's very rigid - you can register with TShortCut, you can register directly with platform codes. You can use simple OnHotKey event, or more robust SC_HOTKEY message. There are couple of demos.

Here is for review


regs

  • Jr. Member
  • **
  • Posts: 77
Re: Global hotkey component
« Reply #1 on: May 31, 2025, 12:58:25 am »
Updated and will reside here
https://github.com/regs01/LazGlobalHotKey


I didn't know there is very specific forum for this. So probably better to move there.
https://forum.lazarus.freepascal.org/index.php/board,19.0.html

Handoko

  • Hero Member
  • *****
  • Posts: 5436
  • My goal: build my own game engine using Lazarus
Re: Global hotkey component
« Reply #2 on: May 31, 2025, 05:58:39 am »
Nice, I may need it in the future.Bookmarked.
Thank you for sharing it.

CM630

  • Hero Member
  • *****
  • Posts: 1402
  • Не съм сигурен, че те разбирам.
    • http://sourceforge.net/u/cm630/profile/
Re: Global hotkey component
« Reply #3 on: May 31, 2025, 11:13:18 pm »
Nice, I may need it in the future.Bookmarked.
Thank you for sharing it.
+1
Лазар 4,0 32 bit (sometimes 64 bit); FPC3,2,2

El Salvador

  • Full Member
  • ***
  • Posts: 140
Re: Global hotkey component
« Reply #4 on: June 04, 2025, 04:49:43 pm »
But does it work with every widgetset? For example, in QT* I used the QT library events hooks. See https://github.com/salvadorbs/AsuiteComps/blob/5fae32f167fbbf019085396da67766fe4992ae34/library/platform/unix/Hotkeys.Manager.Platform.pas#L574

zeljko

  • Hero Member
  • *****
  • Posts: 1763
    • http://wiki.lazarus.freepascal.org/User:Zeljan
Re: Global hotkey component
« Reply #5 on: June 04, 2025, 05:48:07 pm »
He is hooking x11 directly, so should work theoretically for all widgetsets under x11 (just an fish eye in sources).

El Salvador

  • Full Member
  • ***
  • Posts: 140
Re: Global hotkey component
« Reply #6 on: June 04, 2025, 05:56:12 pm »
I saw it too. I don't have an updated and working linux installation, for what I was asking, otherwise I would have tried directly.  ;)

regs

  • Jr. Member
  • **
  • Posts: 77
Re: Global hotkey component
« Reply #7 on: June 07, 2025, 10:46:54 am »
But does it work with every widgetset? For example, in QT* I used the QT library events hooks. See https://github.com/salvadorbs/AsuiteComps/blob/5fae32f167fbbf019085396da67766fe4992ae34/library/platform/unix/Hotkeys.Manager.Platform.pas#L574
It doesn't rely on any widgetset for Unix. Tested GTK2, GTK3, Qt5, Qt6. Should work regardless of widgetset. Should also work not just on Linux, but any Unix with X11. I didn't try FreeBSD though.

 

TinyPortal © 2005-2018