Hello,
following problem ...
... I want to know, which modifier was pressed, when receiving a
KeyPress event in a generalized callback procedure.
I searched comp.lang.tcl on google and found the message on:
http://groups.google.com/group/comp.lang.tcl/tree/browse_frm/thread/dcd8364dd112ebba/8dcf6146d42509b0?rnum=1&hl=en&q=bind+modifier&_done=%2Fgroup%2Fcomp.lang.tcl%2Fbrowse_frm%2Fthread%2Fdcd8364dd112ebba%2F8dcf6146d42509b0%3Fq%3Dbind+modifier%26rnum%3D14%26hl%3Den%26#doc_fe4e360cb85e094d
Now I'm able to detect the Control, Shift and Mod1-5 modifiers, but ...
where is the Alt modifier?
And using these masks from X.h I always found the Mod1 modifier in the
state integer.
So I experimented a bit and ... aha ... Mod1 is my NUM-lock key and
Mod3 is the Scroll-lock key. And the state integer 131072 seems to
stand for the Alt key, but is not documented.
Is there somebody to share his/hers experiences?
And ... wouldn't it be good to extend the documentation to contain such
information about detecting KeyPress/KeyRelease modifiers from the
state substitution? Probably there are some more information about
other substitution to be included?
Best regards,
Martin
UGS - Transforming the Process of Innovation
My test source code for tcl 8.5 to detect the KeyPress/KeyRelease
modifiers:
| # Mod1 == Num
| # Mod3 == Scroll
|
| array set masks [list \
| shift [list [expr {1 << 0}] "Shift-"] \
| lock [list [expr {1 << 1}] "Lock-"] \
| control [list [expr {1 << 2}] "Control-"] \
| mod1 [list [expr {1 << 3}] "Mod1-"] \
| mod2 [list [expr {1 << 4}] "Mod2-"] \
| mod3 [list [expr {1 << 5}] "Mod3-"] \
| mod4 [list [expr {1 << 6}] "Mod4-"] \
| mod5 [list [expr {1 << 7}] "Mod5-"] \
| alt [list [expr {1 << 17}] "Alt-"] \
| ];
|
| proc _Modifier {state} {
| variable masks;
|
| set modifier "";
|
| foreach mask [array names masks] {
| lassign $masks($mask) bits label;
|
| if {$state & $bits} {append modifier $label;};
| }
|
| return [string trimright $modifier "-"];
| }
|
| bind . <KeyPress> {puts "K=%K N=%N A=%A k=%k s=%s ([_Modifier %s])"}
Received on Mon Nov 21 00:37:24 2005