[Gambas-user] How to show a form with keyboard shortcut
HARADA Kazutaka
kazutaka802 at ...1907...
Mon Aug 17 16:53:01 CEST 2009
Sorry fo late reply,
> You can't if you don't have the focus. What you need is a global shortcut,
> which is managed by your desktop environment, or a special program.
>
> For example, in KDE, there is a control panel entry for configuring them.
>
Yes, you are right.
But I'm looking for a window manager (or desktop environment)
independent way.
So I start to write a test program using Xlib with EXTERN declaration
like this.
' Gambas module file
EXTERN XOpenDisplay(DpyName AS String) AS Pointer IN "libX11"
EXTERN XDefaultScreen(Display AS Pointer) AS Integer IN "libX11"
EXTERN XDefaultRootWindow(Display AS Pointer) AS Integer IN "libX11"
EXTERN XSelectInput(Display AS Pointer, Window AS Integer, KeyMask AS
Long) IN "libX11"
EXTERN XNextEvent(Display AS Pointer, XEvent AS Pointer) IN "libX11"
EXTERN XGrabKey(Display AS Pointer, KeyCode AS Integer, Modifiers AS
Integer, Window AS Pointer, OwnEvent AS Boolean, PointerMode AS Integer,
KeyboardMode AS Integer) IN "libX11"
PUBLIC SUB Main()
DIM pDisplay AS Pointer
DIM pRootWindow AS Pointer
DIM pEvent AS Pointer
pDisplay = XOpenDisplay("")
pRootWindow = XDefaultRootWindow(pDisplay)
XSelectInput(pDisplay, pRootWindow, 1) '1 = KeyPressMask
XGrabKey(pDisplay, 95, 0, pRootWindow, FALSE, 1, 1) '95 = F11 key,
1=GrabModeAsync
DO
XNextEvent(pDisplay, pEvent)
PRINT ("Key F11 Pressed")
LOOP
END
When F11 Key, keycode is 95 on my japanese keyboard, is pressed,
It should print the message. But actually program exit with signal 11.
Any comments or suggestions are wlecome.
Regards,
--
--------------------------------------
Kazutaka HARADA
e-mail:kazutaka802 at ...1907...
--------------------------------------
More information about the User
mailing list