📄 gdk-keyboard-handling.html
字号:
<tbody><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> <em class="structfield"><code>keycode</code></em>;</span></p></td><td>the hardware keycode. This is an identifying number for a physical key.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>group</code></em>;</span></p></td><td>indicates movement in a horizontal direction. Usually groups are used for two different languages. In group 0, a key might have two English characters, and in group 1 it might have two Hebrew characters. The Hebrew characters will be printed on the key next to the English characters.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> <em class="structfield"><code>level</code></em>;</span></p></td><td>indicates which symbol on the key will be used, in a vertical direction. So on a standard US keyboard, the key with the number "1" on it also has the exclamation point ("!") character on it. The level indicates whether to use the "1" or the "!" symbol. The letter keys are considered to have a lowercase letter at level 0, and an uppercase letter at level 1, though only the uppercase letter is printed.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3252920"></a><h3><a name="gdk-keymap-get-default"></a>gdk_keymap_get_default ()</h3><a class="indexterm" name="id3252933"></a><pre class="programlisting"><a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a>* gdk_keymap_get_default (void);</pre><p>Returns the <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> attached to the default display.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> attached to the default display.</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3252989"></a><h3><a name="gdk-keymap-get-for-display"></a>gdk_keymap_get_for_display ()</h3><a class="indexterm" name="id3253006"></a><pre class="programlisting"><a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a>* gdk_keymap_get_for_display (<a class="link" href="GdkDisplay.html" title="GdkDisplay">GdkDisplay</a> *display);</pre><p>Returns the <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> attached to <em class="parameter"><code>display</code></em>.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>display</code></em> :</span></p></td><td> the <a class="link" href="GdkDisplay.html" title="GdkDisplay"><span class="type">GdkDisplay</span></a>.</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> the <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> attached to <em class="parameter"><code>display</code></em>.</td></tr></tbody></table></div><p class="since">Since 2.2</p></div><hr><div class="refsect2" lang="en"><a name="id3253108"></a><h3><a name="gdk-keymap-lookup-key"></a>gdk_keymap_lookup_key ()</h3><a class="indexterm" name="id3253121"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> gdk_keymap_lookup_key (<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a> *keymap, const <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey">GdkKeymapKey</a> *key);</pre><p>Looks up the keyval mapped to a keycode/group/level triplet.If no keyval is bound to <em class="parameter"><code>key</code></em>, returns 0. For normal user input,you want to use <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state"><code class="function">gdk_keymap_translate_keyboard_state()</code></a> instead ofthis function, since the effective group/level may not bethe same as the current keyboard state.</p><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>keymap</code></em> :</span></p></td><td> a <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to use the default keymap</td></tr><tr><td><p><span class="term"><em class="parameter"><code>key</code></em> :</span></p></td><td> a <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey"><span class="type">GdkKeymapKey</span></a> with keycode, group, and level initialized</td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> a keyval, or 0 if none was mapped to the given <em class="parameter"><code>key</code></em></td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3253258"></a><h3><a name="gdk-keymap-translate-keyboard-state"></a>gdk_keymap_translate_keyboard_state ()</h3><a class="indexterm" name="id3253272"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> gdk_keymap_translate_keyboard_state (<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a> *keymap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> hardware_keycode, <a class="link" href="gdk-Windows.html#GdkModifierType">GdkModifierType</a> state, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> group, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> *keyval, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *effective_group, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *level, <a class="link" href="gdk-Windows.html#GdkModifierType">GdkModifierType</a> *consumed_modifiers);</pre><p>Translates the contents of a <a class="link" href="gdk-Event-Structures.html#GdkEventKey"><span class="type">GdkEventKey</span></a> into a keyval, effectivegroup, and level. Modifiers that affected the translation andare thus unavailable for application use are returned in<em class="parameter"><code>consumed_modifiers</code></em>. See <code class="function">gdk_keyval_get_keys()</code> for an explanation ofgroups and levels. The <em class="parameter"><code>effective_group</code></em> is the group that wasactually used for the translation; some keys such as Enter are notaffected by the active keyboard group. The <em class="parameter"><code>level</code></em> is derived from<em class="parameter"><code>state</code></em>. For convenience, <a class="link" href="gdk-Event-Structures.html#GdkEventKey"><span class="type">GdkEventKey</span></a> already contains the translatedkeyval, so this function isn't as useful as you might think.</p><p></p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p><em class="parameter"><code>consumed_modifiers</code></em> gives modifiers that should be masked outfrom <em class="parameter"><code>state</code></em> when comparing this key press to a hot key. Forinstance, on a US keyboard, the <code class="literal">plus</code>symbol is shifted, so when comparing a key press to a<code class="literal"><Control>plus</code> accelerator <Shift> shouldbe masked out.</p><div class="informalexample"><pre class="programlisting">/* We want to ignore irrelevant modifiers like ScrollLock */#define ALL_ACCELS_MASK (GDK_CONTROL_MASK | GDK_SHIFT_MASK | GDK_MOD1_MASK)gdk_keymap_translate_keyboard_state (keymap, event->hardware_keycode, event->state, event->group, &keyval, NULL, NULL, &consumed);if (keyval == GDK_PLUS && (event->state & ~consumed & ALL_ACCELS_MASK) == GDK_CONTROL_MASK) /* Control was pressed */</pre></div><p>An older interpretation <em class="parameter"><code>consumed_modifiers</code></em> was that it containedall modifiers that might affect the translation of the key;this allowed accelerators to be stored with irrelevant consumedmodifiers, by doing:</p><div class="informalexample"><pre class="programlisting">/* XXX Don't do this XXX */if (keyval == accel_keyval && (event->state & ~consumed & ALL_ACCELS_MASK) == (accel_mods & ~consumed)) /* Accelerator was pressed */</pre></div><p>However, this did not work if multi-modifier combinations wereused in the keymap, since, for instance, <code class="literal"><Control></code>would be masked out even if only <code class="literal"><Control><Alt></code>was used in the keymap. To support this usage as well as well aspossible, all <span class="emphasis"><em>single modifier</em></span> combinationsthat could affect the key for any combination of modifiers willbe returned in <em class="parameter"><code>consumed_modifiers</code></em>; multi-modifier combinationsare returned only when actually found in <em class="parameter"><code>state</code></em>. When you storeaccelerators, you should always store them with consumed modifiersremoved. Store <code class="literal"><Control>plus</code>,not <code class="literal"><Control><Shift>plus</code>,</p></div><p></p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><em class="parameter"><code>keymap</code></em> :</span></p></td><td> a <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a>, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a> to use the default</td></tr><tr><td><p><span class="term"><em class="parameter"><code>hardware_keycode</code></em> :</span></p></td><td> a keycode</td></tr><tr><td><p><span class="term"><em class="parameter"><code>state</code></em> :</span></p></td><td> a modifier state </td></tr><tr><td><p><span class="term"><em class="parameter"><code>group</code></em> :</span></p></td><td> active keyboard group</td></tr><tr><td><p><span class="term"><em class="parameter"><code>keyval</code></em> :</span></p></td><td> return location for keyval, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>effective_group</code></em> :</span></p></td><td> return location for effective group, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>level</code></em> :</span></p></td><td> return location for level, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><em class="parameter"><code>consumed_modifiers</code></em> :</span></p></td><td> return location for modifiers that were used to determine the group or level, or <ahref="/usr/share/gtk-doc/html/liboil/liboil-liboiljunk.html#NULL:CAPS"><code class="literal">NULL</code></a></td></tr><tr><td><p><span class="term"><span class="emphasis"><em>Returns</em></span> :</span></p></td><td> <ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if there was a keyval bound to the keycode/state/group</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3253741"></a><h3><a name="gdk-keymap-get-entries-for-keyval"></a>gdk_keymap_get_entries_for_keyval ()</h3><a class="indexterm" name="id3253756"></a><pre class="programlisting"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a> gdk_keymap_get_entries_for_keyval (<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a> *keymap, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> keyval, <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey">GdkKeymapKey</a> **keys, <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *n_keys);</pre><p>Obtains a list of keycode/group/level combinations that willgenerate <em class="parameter"><code>keyval</code></em>. Groups and levels are two kinds of keyboard mode;in general, the level determines whether the top or bottom symbol
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -