Source

cappuccino-docs / cappuccino docs / cappuccino.org / learn / documentation / _c_p_platform_window_09_d_o_m_keys_8j_source.html

Full commit
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_platform_window_09_d_o_m_keys_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:42 GMT -->
<head>
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
<title>Cappuccino API: AppKit/Platform/DOM/CPPlatformWindow+DOMKeys.j Source File</title>
<link href="tabs.css" rel="stylesheet" type="text/css"/>
<link href="doxygen.css" rel="stylesheet" type="text/css"/>
</head>
<body>
<!-- Generated by Doxygen 1.6.1 -->
<div class="navigation" id="top">
  <div class="tabs">
    <ul>
      <li><a href="main.html"><span>Main&nbsp;Page</span></a></li>
      <li><a href="pages.html"><span>Related&nbsp;Pages</span></a></li>
      <li><a href="modules.html"><span>Modules</span></a></li>
      <li><a href="annotated.html"><span>Classes</span></a></li>
      <li class="current"><a href="files.html"><span>Files</span></a></li>
    </ul>
  </div>
  <div class="tabs">
    <ul>
      <li><a href="files.html"><span>File&nbsp;List</span></a></li>
      <li><a href="globals.html"><span>File&nbsp;Members</span></a></li>
    </ul>
  </div>
<h1>AppKit/Platform/DOM/CPPlatformWindow+DOMKeys.j</h1><a href="_c_p_platform_window_09_d_o_m_keys_8j.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span>
<a name="l00002"></a>00002 <span class="comment"> * CPPlatformWindow+DOMKeys.j</span>
<a name="l00003"></a>00003 <span class="comment"> * AppKit</span>
<a name="l00004"></a>00004 <span class="comment"> *</span>
<a name="l00005"></a>00005 <span class="comment"> * Created by Ross Boucher.</span>
<a name="l00006"></a>00006 <span class="comment"> * Copyright 2009, 280 North, Inc.</span>
<a name="l00007"></a>00007 <span class="comment"> *</span>
<a name="l00008"></a>00008 <span class="comment"> * This library is free software; you can redistribute it and/or</span>
<a name="l00009"></a>00009 <span class="comment"> * modify it under the terms of the GNU Lesser General Public</span>
<a name="l00010"></a>00010 <span class="comment"> * License as published by the Free Software Foundation; either</span>
<a name="l00011"></a>00011 <span class="comment"> * version 2.1 of the License, or (at your option) any later version.</span>
<a name="l00012"></a>00012 <span class="comment"> *</span>
<a name="l00013"></a>00013 <span class="comment"> * This library is distributed in the hope that it will be useful,</span>
<a name="l00014"></a>00014 <span class="comment"> * but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<a name="l00015"></a>00015 <span class="comment"> * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU</span>
<a name="l00016"></a>00016 <span class="comment"> * Lesser General Public License for more details.</span>
<a name="l00017"></a>00017 <span class="comment"> *</span>
<a name="l00018"></a>00018 <span class="comment"> * You should have received a copy of the GNU Lesser General Public</span>
<a name="l00019"></a>00019 <span class="comment"> * License along with this library; if not, write to the Free Software</span>
<a name="l00020"></a>00020 <span class="comment"> * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA</span>
<a name="l00021"></a>00021 <span class="comment"> */</span>
<a name="l00022"></a>00022  
<a name="l00023"></a>00023 <span class="comment">// Keycodes taken and modified from Google Closure, available under Apache 2 License</span>
<a name="l00024"></a>00024 
<a name="l00025"></a><a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">00025</a> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a> = {
<a name="l00026"></a>00026   BACKSPACE: 8,
<a name="l00027"></a>00027   TAB: 9,
<a name="l00028"></a>00028   NUM_CENTER: 12,
<a name="l00029"></a>00029   ENTER: 13,
<a name="l00030"></a>00030   SHIFT: 16,
<a name="l00031"></a>00031   CTRL: 17,
<a name="l00032"></a>00032   ALT: 18,
<a name="l00033"></a>00033   PAUSE: 19,
<a name="l00034"></a>00034   CAPS_LOCK: 20,
<a name="l00035"></a>00035   ESC: 27,
<a name="l00036"></a>00036   SPACE: 32,
<a name="l00037"></a>00037   PAGE_UP: 33,     <span class="comment">// also NUM_NORTH_EAST</span>
<a name="l00038"></a>00038   PAGE_DOWN: 34,   <span class="comment">// also NUM_SOUTH_EAST</span>
<a name="l00039"></a>00039   END: 35,         <span class="comment">// also NUM_SOUTH_WEST</span>
<a name="l00040"></a>00040   HOME: 36,        <span class="comment">// also NUM_NORTH_WEST</span>
<a name="l00041"></a>00041   LEFT: 37,        <span class="comment">// also NUM_WEST</span>
<a name="l00042"></a>00042   UP: 38,          <span class="comment">// also NUM_NORTH</span>
<a name="l00043"></a>00043   RIGHT: 39,       <span class="comment">// also NUM_EAST</span>
<a name="l00044"></a>00044   DOWN: 40,        <span class="comment">// also NUM_SOUTH</span>
<a name="l00045"></a>00045   PRINT_SCREEN: 44,
<a name="l00046"></a>00046   INSERT: 45,      <span class="comment">// also NUM_INSERT</span>
<a name="l00047"></a>00047   DELETE: 46,      <span class="comment">// also NUM_DELETE</span>
<a name="l00048"></a>00048   ZERO: 48,
<a name="l00049"></a>00049   ONE: 49,
<a name="l00050"></a>00050   TWO: 50,
<a name="l00051"></a>00051   THREE: 51,
<a name="l00052"></a>00052   FOUR: 52,
<a name="l00053"></a>00053   FIVE: 53,
<a name="l00054"></a>00054   SIX: 54,
<a name="l00055"></a>00055   SEVEN: 55,
<a name="l00056"></a>00056   EIGHT: 56,
<a name="l00057"></a>00057   NINE: 57,
<a name="l00058"></a>00058   QUESTION_MARK: 63, <span class="comment">// needs localization</span>
<a name="l00059"></a>00059   A: 65,
<a name="l00060"></a>00060   B: 66,
<a name="l00061"></a>00061   C: 67,
<a name="l00062"></a>00062   D: 68,
<a name="l00063"></a>00063   E: 69,
<a name="l00064"></a>00064   F: 70,
<a name="l00065"></a>00065   G: 71,
<a name="l00066"></a>00066   <a class="code" href="_c_g_context_v_m_l_8j.html#abd057520df7a5dc64fe29b4edd3166a3">H</a>: 72,
<a name="l00067"></a>00067   I: 73,
<a name="l00068"></a>00068   J: 74,
<a name="l00069"></a>00069   K: 75,
<a name="l00070"></a>00070   L: 76,
<a name="l00071"></a>00071   M: 77,
<a name="l00072"></a>00072   N: 78,
<a name="l00073"></a>00073   O: 79,
<a name="l00074"></a>00074   P: 80,
<a name="l00075"></a>00075   Q: 81,
<a name="l00076"></a>00076   R: 82,
<a name="l00077"></a>00077   S: 83,
<a name="l00078"></a>00078   T: 84,
<a name="l00079"></a>00079   U: 85,
<a name="l00080"></a>00080   V: 86,
<a name="l00081"></a>00081   <a class="code" href="_c_g_context_v_m_l_8j.html#a0b02f09bf5aa8ca34f72487f7d0e6e63">W</a>: 87,
<a name="l00082"></a>00082   X: 88,
<a name="l00083"></a>00083   Y: 89,
<a name="l00084"></a>00084   <a class="code" href="_c_g_context_v_m_l_8j.html#a0e13cb15ff3d6fbe4b9cd26ef446070e">Z</a>: 90,
<a name="l00085"></a>00085   META: 91,
<a name="l00086"></a>00086   CONTEXT_MENU: 93,
<a name="l00087"></a>00087   NUM_ZERO: 96,
<a name="l00088"></a>00088   NUM_ONE: 97,
<a name="l00089"></a>00089   NUM_TWO: 98,
<a name="l00090"></a>00090   NUM_THREE: 99,
<a name="l00091"></a>00091   NUM_FOUR: 100,
<a name="l00092"></a>00092   NUM_FIVE: 101,
<a name="l00093"></a>00093   NUM_SIX: 102,
<a name="l00094"></a>00094   NUM_SEVEN: 103,
<a name="l00095"></a>00095   NUM_EIGHT: 104,
<a name="l00096"></a>00096   NUM_NINE: 105,
<a name="l00097"></a>00097   NUM_MULTIPLY: 106,
<a name="l00098"></a>00098   NUM_PLUS: 107,
<a name="l00099"></a>00099   NUM_MINUS: 109,
<a name="l00100"></a>00100   NUM_PERIOD: 110,
<a name="l00101"></a>00101   NUM_DIVISION: 111,
<a name="l00102"></a>00102   F1: 112,
<a name="l00103"></a>00103   F2: 113,
<a name="l00104"></a>00104   F3: 114,
<a name="l00105"></a>00105   F4: 115,
<a name="l00106"></a>00106   F5: 116,
<a name="l00107"></a>00107   F6: 117,
<a name="l00108"></a>00108   F7: 118,
<a name="l00109"></a>00109   F8: 119,
<a name="l00110"></a>00110   F9: 120,
<a name="l00111"></a>00111   F10: 121,
<a name="l00112"></a>00112   F11: 122,
<a name="l00113"></a>00113   F12: 123,
<a name="l00114"></a>00114   NUMLOCK: 144,
<a name="l00115"></a>00115   SEMICOLON: 186,            <span class="comment">// needs localization</span>
<a name="l00116"></a>00116   DASH: 189,                 <span class="comment">// needs localization</span>
<a name="l00117"></a>00117   EQUALS: 187,               <span class="comment">// needs localization</span>
<a name="l00118"></a>00118   COMMA: 188,                <span class="comment">// needs localization</span>
<a name="l00119"></a>00119   PERIOD: 190,               <span class="comment">// needs localization</span>
<a name="l00120"></a>00120   SLASH: 191,                <span class="comment">// needs localization</span>
<a name="l00121"></a>00121   APOSTROPHE: 192,           <span class="comment">// needs localization</span>
<a name="l00122"></a>00122   SINGLE_QUOTE: 222,         <span class="comment">// needs localization</span>
<a name="l00123"></a>00123   OPEN_SQUARE_BRACKET: 219,  <span class="comment">// needs localization</span>
<a name="l00124"></a>00124   BACKSLASH: 220,            <span class="comment">// needs localization</span>
<a name="l00125"></a>00125   CLOSE_SQUARE_BRACKET: 221, <span class="comment">// needs localization</span>
<a name="l00126"></a>00126   WIN_KEY: 224,
<a name="l00127"></a>00127   MAC_FF_META: 224,          <span class="comment">// Firefox (Gecko) fires this for the meta key instead of 91</span>
<a name="l00128"></a>00128   WIN_IME: 229
<a name="l00129"></a>00129 };
<a name="l00130"></a>00130 
<a name="l00131"></a>00131 
<a name="l00159"></a><a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a6c28f3b7184efebf08d144735b538bb0">00159</a> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.firesKeyPressEvent = function(keyCode, opt_heldKeyCode, opt_shiftKey, opt_ctrlKey, opt_altKey) 
<a name="l00160"></a>00160 {
<a name="l00161"></a>00161     <span class="keywordflow">if</span> (!<a class="code" href="_c_p_compatibility_8j.html#a1fbfe7ca6b2cef354ecfe78f6cfd6659">CPFeatureIsCompatible</a>(<a class="code" href="_c_p_compatibility_8j.html#af88ce1b8250bde44f08bb7d79b6c6cdc">CPJavascriptRemedialKeySupport</a>))
<a name="l00162"></a>00162         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00163"></a>00163 
<a name="l00164"></a>00164     <span class="keywordflow">if</span> (<a class="code" href="_c_p_compatibility_8j.html#ae1fbcf225a17315d7dca192a87f1a6f5">CPBrowserIsOperatingSystem</a>(<a class="code" href="_c_p_compatibility_8j.html#aff6eb358aa28aa56c8451ea9683a9d18">CPMacOperatingSystem</a>) &amp;&amp; opt_altKey) 
<a name="l00165"></a>00165         <span class="keywordflow">return</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.isCharacterKey(keyCode);
<a name="l00166"></a>00166 
<a name="l00167"></a>00167     <span class="comment">// Alt but not AltGr which is represented as Alt+Ctrl.</span>
<a name="l00168"></a>00168     <span class="keywordflow">if</span> (opt_altKey &amp;&amp; !opt_ctrlKey)
<a name="l00169"></a>00169         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00170"></a>00170 
<a name="l00171"></a>00171     <span class="comment">// Saves Ctrl or Alt + key for IE7, which won&apos;t fire keypress.</span>
<a name="l00172"></a>00172     <span class="keywordflow">if</span> (<a class="code" href="_c_p_compatibility_8j.html#a882b09585ca8bc50bbc572b58992fe73">CPBrowserIsEngine</a>(<a class="code" href="_c_p_compatibility_8j.html#ad84a8a1f8d8e48b96cbe2dbff12771dd">CPInternetExplorerBrowserEngine</a>) &amp;&amp; !opt_shiftKey &amp;&amp; (opt_ctrlKey || opt_altKey))
<a name="l00173"></a>00173         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00174"></a>00174 
<a name="l00175"></a>00175     <span class="comment">// When Ctrl+&lt;somekey&gt; is held in IE, it only fires a keypress once, but it</span>
<a name="l00176"></a>00176     <span class="comment">// continues to fire keydown events as the event repeats.</span>
<a name="l00177"></a>00177     <span class="keywordflow">if</span> (<a class="code" href="_c_p_compatibility_8j.html#a882b09585ca8bc50bbc572b58992fe73">CPBrowserIsEngine</a>(<a class="code" href="_c_p_compatibility_8j.html#ad84a8a1f8d8e48b96cbe2dbff12771dd">CPInternetExplorerBrowserEngine</a>) &amp;&amp; opt_ctrlKey &amp;&amp; opt_heldKeyCode == keyCode)
<a name="l00178"></a>00178         <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00179"></a>00179 
<a name="l00180"></a>00180     <span class="keywordflow">switch</span> (keyCode)
<a name="l00181"></a>00181     {
<a name="l00182"></a>00182         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.ENTER: <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00183"></a>00183         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.ESC:   <span class="keywordflow">return</span> !<a class="code" href="_c_p_compatibility_8j.html#a882b09585ca8bc50bbc572b58992fe73">CPBrowserIsEngine</a>(<a class="code" href="_c_p_compatibility_8j.html#ac5b903ab4837fb9d228e030c08424920">CPWebKitBrowserEngine</a>);
<a name="l00184"></a>00184     }
<a name="l00185"></a>00185 
<a name="l00186"></a>00186     <span class="keywordflow">return</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.isCharacterKey(keyCode);
<a name="l00187"></a>00187 };
<a name="l00188"></a>00188 
<a name="l00189"></a>00189 
<a name="l00196"></a>00196 <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.isCharacterKey = function(keyCode) 
<a name="l00197"></a>00197 {
<a name="l00198"></a>00198     <span class="keywordflow">if</span> (keyCode &gt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.ZERO &amp;&amp; keyCode &lt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NINE)
<a name="l00199"></a>00199         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00200"></a>00200 
<a name="l00201"></a>00201     <span class="keywordflow">if</span> (keyCode &gt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_ZERO &amp;&amp; keyCode &lt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_MULTIPLY)
<a name="l00202"></a>00202         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00203"></a>00203 
<a name="l00204"></a>00204     <span class="keywordflow">if</span> (keyCode &gt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.A &amp;&amp; keyCode &lt;= <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.Z)
<a name="l00205"></a>00205         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00206"></a>00206 
<a name="l00207"></a>00207     <span class="keywordflow">switch</span> (keyCode) 
<a name="l00208"></a>00208     {
<a name="l00209"></a>00209         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.SPACE:
<a name="l00210"></a>00210         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.QUESTION_MARK:
<a name="l00211"></a>00211         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_PLUS:
<a name="l00212"></a>00212         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_MINUS:
<a name="l00213"></a>00213         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_PERIOD:
<a name="l00214"></a>00214         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.NUM_DIVISION:
<a name="l00215"></a>00215         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.SEMICOLON:
<a name="l00216"></a>00216         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.DASH:
<a name="l00217"></a>00217         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.EQUALS:
<a name="l00218"></a>00218         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.COMMA:
<a name="l00219"></a>00219         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.PERIOD:
<a name="l00220"></a>00220         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.SLASH:
<a name="l00221"></a>00221         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.APOSTROPHE:
<a name="l00222"></a>00222         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.SINGLE_QUOTE:
<a name="l00223"></a>00223         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.OPEN_SQUARE_BRACKET:
<a name="l00224"></a>00224         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.BACKSLASH:
<a name="l00225"></a>00225         <span class="keywordflow">case</span> <a class="code" href="_c_p_platform_window_09_d_o_m_keys_8j.html#a52371807f279187842ce48033db5512a">CPKeyCodes</a>.CLOSE_SQUARE_BRACKET:
<a name="l00226"></a>00226             <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00227"></a>00227 
<a name="l00228"></a>00228         <span class="keywordflow">default</span>:
<a name="l00229"></a>00229             <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00230"></a>00230     }
<a name="l00231"></a>00231 }
</pre></div></div>
<hr size="1"/><address style="text-align: right;"><small>Generated on Tue Apr 6 10:32:56 2010 for Cappuccino API by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.6.1 </small></address>
</body>

<!-- Mirrored from cappuccino.org/learn/documentation/_c_p_platform_window_09_d_o_m_keys_8j_source.html by HTTrack Website Copier/3.x [XR&CO'2006], Mon, 20 Sep 2010 02:19:42 GMT -->
</html>