1

I am new here, so I did not want to bother you with little questions, it took me time, but until now I managed to google everything. I am a Delphi programmer, who switched to Linux, therefore to GTK2 Lazarus.

Now, I can't seem to find a way to make a hotkey work in Lazarus (Free Pascal, very similar to Delphi). There is no RegisterHotKey function in components. I searched all *.pas files. Even if I did register the hotkey, Lazarus does not seem to support messages. I don't know where to start.

EDIT: I need the global hotkey on Linux.

Vlastimil Burián
  • 3,024
  • 2
  • 31
  • 52
  • How to do this on Linux. Of course, Linux is just the kernel, being pedantic. There are many GUI toolkits. Which one does Lazarus use? – David Heffernan Sep 14 '15 at 13:42
  • I am on Linux Mint 17.2. – Vlastimil Burián Sep 14 '15 at 13:43
  • I think what counts is the toolkit that Lazarus is built on. Or perhaps it supports multiple toolkits. In which case, which are you using? – David Heffernan Sep 14 '15 at 13:45
  • I may not fully understand your question. I am new to Linux, I use GTK version of Lazarus, I believe. – Vlastimil Burián Sep 14 '15 at 13:46
  • 1
    So my guess is that your question becomes how to implement global hot keys on GTK – David Heffernan Sep 14 '15 at 13:55
  • `RegisterHotKey` is a WinAPI call - naturally this is platform specific. In linux the implementation for each window manager and framework will be different (Gnome and its various WMs, KDE, X11, etc), if it is supported at all. I don't think that GTK has support for this type of global hotkey, but I may be wrong... – J... Sep 14 '15 at 14:49
  • 2
    You need to look for a `RegisterHotKey` equivalent. The code [in this question](http://stackoverflow.com/questions/27171400/register-hotkey-with-only-modifiers-in-linux) uses `XGrabKey` and should work for you, provided you can access the X11 API calls from Lazarus. If you can't do that, you will need to create a workaround, e.g. have a separate small C program that captures the hotkey using `XGrabKey` and is invoked by Lazarus. – user4815162342 Sep 15 '15 at 09:00

0 Answers0