Re: [[gnomemm] Key Events]
- From: "Andrew E. Makeev" <andrew solvo ru>
- To: Murray Cumming <murrayc usa net>
- Cc: Deepak Chandran <deepakc dpsl net>, gnomemm-list <gnomemm-list gnome org>
- Subject: Re: [[gnomemm] Key Events]
- Date: Mon, 24 Feb 2003 11:56:24 +0300
Murray Cumming wrote:
Why not use the normal gtkmm or gnomemm accelerator key systems?
Deepak Chandran <DeepakC dpsl net> wrote:
Hi!!
We are developing an application in gnome-mm.
The application needs to allow user to operate it using key combinations.
We are providing the user "CTRL" + Key combinations for various operations
*****Attached is the code snippet for the same**************
bool window::on_key_press(GdkEventKey* key)
{
if (( key->keyval == GDK_E || key->keyval == GDK_e)
&& ( key->state == GDK_CONTROL_MASK ))
{
/* IF CTLR + e / CTLR + E perform required operation*/
}
}
**************************************************
When we execute the above code, it works fine.
But when "Num Lock" is ON, the above "if" condition fails.
We found that when the "Num Lock" is activated, the "key->state" is
incremented by a factor of 16. This increment is not consistent for all the
keys.
This is causing a problem for as we are not able to find if the Num Lock is
activated or not.
And If activated what is the key->state behaviour for various keys.
Is there some way to get the "key->state" irrespective of the Num Lock key
state ?
Guys, it is not GTK question, actually :).
Any mask requires bitwise OR, AND, XOR, NOT operation instead of logical
EQ, etc.
So, expression like
key->state & GDK_CONTROL_MASK
is going to work for Ctrl+<key> regardless any other STATE-key is
activated also.
However, I guess, you won't to have your binding activated with
Ctrl+Alt+<key> (for example). Then you have to build STATE expression
wisely to filter valid masks (probably, normal key-accelerator system
does it for you).
Num Lock modifier is mapped to GDK_MOD2_MASK, usually, you could check
it with 'xmodmap -pm' command in Linux shell.
Regards,
-andrew
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]