nobody at rubyforge.org
2007-Jul-04 19:32 UTC
[Wxruby-development] [1107] trunk/wxruby2: Add the 2.8 get_modifiers method to KeyEvent; remove some deprecated
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><style type="text/css"><!-- #msg dl { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; } #msg dt { float: left; width: 6em; font-weight: bold; } #msg dt:after { content:'':'';} #msg dl, #msg dt, #msg ul, #msg li, #header, #footer { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; } #msg dl a { font-weight: bold} #msg dl a:link { color:#fc3; } #msg dl a:active { color:#ff0; } #msg dl a:visited { color:#cc6; } h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; } #msg pre { overflow: auto; background: #ffc; border: 1px #fc0 solid; padding: 6px; } #msg ul, pre { overflow: auto; } #header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; } #patch { width: 100%; } #patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;} #patch .propset h4, #patch .binary h4 {margin:0;} #patch pre {padding:0;line-height:1.2em;margin:0;} #patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;} #patch .propset .diff, #patch .binary .diff {padding:10px 0;} #patch span {display:block;padding:0 10px;} #patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;} #patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;} #patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;} #patch .lines, .info {color:#888;background:#fff;} --></style> <title>[1107] trunk/wxruby2: Add the 2.8 get_modifiers method to KeyEvent; remove some deprecated</title> </head> <body> <div id="msg"> <dl> <dt>Revision</dt> <dd>1107</dd> <dt>Author</dt> <dd>brokentoy</dd> <dt>Date</dt> <dd>2007-07-04 15:32:50 -0400 (Wed, 04 Jul 2007)</dd> </dl> <h3>Log Message</h3> <pre>Add the 2.8 get_modifiers method to KeyEvent; remove some deprecated direct member access; document</pre> <h3>Modified Paths</h3> <ul> <li><a href="#trunkwxruby2doctextilekeyeventtxtl">trunk/wxruby2/doc/textile/keyevent.txtl</a></li> <li><a href="#trunkwxruby2swigclassesincludewxKeyEventh">trunk/wxruby2/swig/classes/include/wxKeyEvent.h</a></li> </ul> </div> <div id="patch"> <h3>Diff</h3> <a id="trunkwxruby2doctextilekeyeventtxtl"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/doc/textile/keyevent.txtl (1106 => 1107)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/doc/textile/keyevent.txtl        2007-07-04 19:27:15 UTC (rev 1106) +++ trunk/wxruby2/doc/textile/keyevent.txtl        2007-07-04 19:32:50 UTC (rev 1107) </span><span class="lines">@@ -28,7 +28,7 @@ </span><span class="cx"> Although in this simple case it is clear that the correct key code could be </span><span class="cx"> found in the key down event handler by checking the value returned by </span><span class="cx"> "shift_down()":#KeyEvent_shiftdown(), in general you should use </span><del>-@EVT_CHAR@ for this as for non alphanumeric keys the translation is </del><ins>+@EVT_CHAR@ for this as for non-alphanumeric keys the translation is </ins><span class="cx"> keyboard-layout dependent and can only be done properly by the system itself. </span><span class="cx"> </span><span class="cx"> Another kind of translation is done when the control key is pressed: for </span><span class="lines">@@ -74,18 +74,12 @@ </span><span class="cx"> </span><span class="cx"> h2. Methods </span><span class="cx"> </span><del>-* "KeyEvent#m__alt_down":#KeyEvent_maltdown -* "KeyEvent#m__control_down":#KeyEvent_mcontroldown -* "KeyEvent#m__key_code":#KeyEvent_mkeycode -* "KeyEvent#m__meta_down":#KeyEvent_mmetadown -* "KeyEvent#m__shift_down":#KeyEvent_mshiftdown -* "KeyEvent#m__x":#KeyEvent_mx -* "KeyEvent#m__y":#KeyEvent_my </del><span class="cx"> * "KeyEvent.new":#KeyEvent_new </span><span class="cx"> * "KeyEvent#alt_down":#KeyEvent_altdown </span><span class="cx"> * "KeyEvent#cmd_down":#KeyEvent_cmddown </span><span class="cx"> * "KeyEvent#control_down":#KeyEvent_controldown </span><span class="cx"> * "KeyEvent#get_key_code":#KeyEvent_getkeycode </span><ins>+* "KeyEvent#get_modifiers":#KeyEvent_getmodifiers </ins><span class="cx"> * "KeyEvent#get_position":#KeyEvent_getposition </span><span class="cx"> * "KeyEvent#get_raw_key_code":#KeyEvent_getrawkeycode </span><span class="cx"> * "KeyEvent#get_raw_key_flags":#KeyEvent_getrawkeyflags </span><span class="lines">@@ -98,57 +92,6 @@ </span><span class="cx"> </span><span class="cx"> </div> </span><span class="cx"> </span><del>- - -h3(#KeyEvent_maltdown). KeyEvent#m__alt_down - -boolm_altDown - -true if the Alt key is pressed down. - - -h3(#KeyEvent_mcontroldown). KeyEvent#m__control_down - -boolm_controlDown - -true if control is pressed down. - - -h3(#KeyEvent_mkeycode). KeyEvent#m__key_code - -longm_keyCode - -Virtual keycode. See "Keycodes":keycodes.html for a list of identifiers. - - -h3(#KeyEvent_mmetadown). KeyEvent#m__meta_down - -boolm_metaDown - -true if the Meta key is pressed down. - - -h3(#KeyEvent_mshiftdown). KeyEvent#m__shift_down - -boolm_shiftDown - -true if shift is pressed down. - - -h3(#KeyEvent_mx). KeyEvent#m__x - -intm_x - -X position of the event. - - -h3(#KeyEvent_my). KeyEvent#m__y - -intm_y - -Y position of the event. - - </del><span class="cx"> h3(#KeyEvent_new). KeyEvent.new </span><span class="cx"> </span><span class="cx"> *KeyEvent.new*(%(arg-type)TYPE% keyEventType) </span><span class="lines">@@ -162,18 +105,21 @@ </span><span class="cx"> </span><span class="cx"> Returns true if the Alt key was down at the time of the key event. </span><span class="cx"> </span><ins>+Notice that "get_modifiers":#KeyEvent_getmodifiers is easier to use +correctly than this function so you should consider using it in new code. </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> h3(#KeyEvent_cmddown). KeyEvent#cmd_down </span><span class="cx"> </span><span class="cx"> Boolean *cmd_down*() </span><span class="cx"> </span><del>-"Cmd" is a pseudo key which is the same as Control for PC and Unix platforms -but the special "Apple" (a.k.a as "Command") key under Macs: it makes often -sense to use it instead of, say, ControlDown() because Cmd key is used for the -same thing under Mac as Ctrl elsewhere (but Ctrl still exists, just not used -for this purpose under Mac). So for non-Mac platforms this is the same as -"control_down()":#KeyEvent_controldown() and under Mac this is the same -as "meta_down()":#KeyEvent_metadown(). </del><ins>+Cmd is a pseudo key which is the same as Control for PC and Unix +platforms but the special Apple (a.k.a as Command) key under +Macs: it makes often sense to use it instead of, say, ControlDown() because Cmd +key is used for the same thing under Mac as Ctrl elsewhere (but Ctrl still +exists, just not used for this purpose under Mac). So for non-Mac platforms +this is the same as "control_down()":#KeyEvent_controldown() and under +Mac this is the same as "meta_down()":#KeyEvent_metadown(). </ins><span class="cx"> </span><span class="cx"> </span><span class="cx"> h3(#KeyEvent_controldown). KeyEvent#control_down </span><span class="lines">@@ -182,7 +128,10 @@ </span><span class="cx"> </span><span class="cx"> Returns true if the control key was down at the time of the key event. </span><span class="cx"> </span><ins>+Notice that "get_modifiers":#KeyEvent_getmodifiers is easier to use +correctly than this function so you should consider using it in new code. </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> h3(#KeyEvent_getkeycode). KeyEvent#get_key_code </span><span class="cx"> </span><span class="cx"> Integer *get_key_code*() </span><span class="lines">@@ -198,6 +147,35 @@ </span><span class="cx"> "get_unicode_key":#KeyEvent_getunicodekey. </span><span class="cx"> </span><span class="cx"> </span><ins>+h3(#KeyEvent_getmodifiers). KeyEvent#get_modifiers + + Integer *get_modifiers*() + +Return the bitmask of modifier keys which were pressed when this event +happened. See "key modifier constants":keymodifiers.html for the full list +of modifiers. + +Notice that this function is easier to use correctly than, for example, +"control_down":#KeyEvent_controldown because when using the latter you +also have to remember to test that none of the other modifiers is pressed: + + + if ( control_down && ! alt_down && ! shift_down && ! meta_down ) + ... handle Ctrl-XXX ... + + +and forgetting to do it can result in serious program bugs (e.g. program not +working with European keyboard layout where AltGr key which is seen by +the program as combination of Ctrl and Alt is used). On the +other hand, you can simply write + + + if ( get_modifiers == Wx::MOD_CONTROL ) + ... handle Ctrl-XXX ... + + +with this function. + </ins><span class="cx"> h3(#KeyEvent_getposition). KeyEvent#get_position </span><span class="cx"> </span><span class="cx"> "Point":point.html *get_position*() </span><span class="lines">@@ -271,10 +249,16 @@ </span><span class="cx"> </span><span class="cx"> Returns true if the Meta key was down at the time of the key event. </span><span class="cx"> </span><ins>+Notice that "get_modifiers":#KeyEvent_getmodifiers is easier to use +correctly than this function so you should consider using it in new code. </ins><span class="cx"> </span><ins>+ </ins><span class="cx"> h3(#KeyEvent_shiftdown). KeyEvent#shift_down </span><span class="cx"> </span><span class="cx"> Boolean *shift_down*() </span><span class="cx"> </span><span class="cx"> Returns true if the shift key was down at the time of the key event. </span><span class="cx"> </span><ins>+Notice that "get_modifiers":#KeyEvent_getmodifiers is easier to use +correctly than this function so you should consider using it in new code. + </ins></span></pre></div> <a id="trunkwxruby2swigclassesincludewxKeyEventh"></a> <div class="modfile"><h4>Modified: trunk/wxruby2/swig/classes/include/wxKeyEvent.h (1106 => 1107)</h4> <pre class="diff"><span> <span class="info">--- trunk/wxruby2/swig/classes/include/wxKeyEvent.h        2007-07-04 19:27:15 UTC (rev 1106) +++ trunk/wxruby2/swig/classes/include/wxKeyEvent.h        2007-07-04 19:32:50 UTC (rev 1107) </span><span class="lines">@@ -15,6 +15,7 @@ </span><span class="cx"> long GetX() const; </span><span class="cx"> long GetY() const; </span><span class="cx"> bool MetaDown() const; </span><ins>+ int GetModifiers() const; </ins><span class="cx"> wxPoint GetPosition() const; </span><span class="cx"> void GetPosition(long * x , long * y ) const; </span><span class="cx"> bool HasModifiers() const; </span><span class="lines">@@ -23,14 +24,6 @@ </span><span class="cx"> // override pure virtual methods from base classes </span><span class="cx"> virtual wxEvent* Clone() const; </span><span class="cx"> </span><del>- wxCoord m_x, m_y; - - long m_keyCode; - - bool m_controlDown; - bool m_shiftDown; - bool m_altDown; - bool m_metaDown; </del><span class="cx"> bool m_scanCode; </span><span class="cx"> </span><span class="cx"> #if wxUSE_UNICODE </span></span></pre> </div> </div> </body> </html>