I have written an application to call functions on particular key
combinations, however, I have found some discrepancies between how Windows
and Linux define what should be the same key press event.
In my example, I am attempting to capture Ctrl+r (case sensitive) to call a
function.
On Linux, the event->state returned is a combination of the bits
GDK_CONTROL_MASK and GDK_MOD2_MASK.
On Windows, the event->state is different, it is only GDK_CONTROL_MASK.
As a result, I thought, i would have a simple preprocessor definition (as
below):
#ifdef WIN32
mod = (event->state & GDK_CONTROL_MASK);
#else
mod = (event->state & GDK_CONTROL_MASK) && (event->state &
GDK_MOD2_MASK);
#endif
I log everything to screen, and from the output I can see there is also a
difference in the event->keyval returned.
On Linux it is GDK_r (0x72) which is defined clearly in gdkkeysyms.h.
On Windows it is exactly the same, and when I press 'r' (on its own) it
returns the correct value. When I press 'r' with 'Ctrl' if returns GDK_R
(0x52).
Is this a bug?
I would expect that to happen if I press Shift+r, but not Ctrl+r.
The code I use is:
/*
* CONTROL shortcuts
*/
if(mod == 1 && (event->keyval == GDK_r))
{
/* retrieve call ... */
}
The output I get (for just pressing 'r') is:
19:06:27:OC:32: oc_gtk_ops_handle_shortcut: key pressed, type:8,
window:0x0138bfb8, state:0, keyval:0x00000072, code:0x00000052, group:0
The output I get (for pressing 'Ctrl+r') is:
19:06:15:OC:32: oc_gtk_ops_handle_shortcut: key pressed, type:8,
window:0x0138bfb8, state:4, keyval:0x00000052, code:0x00000052, group:0
Any ideas?
Regards,
Martyn
Regards,
Martyn
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.