⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gdk-keyboard-handling.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 4 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Key Values</title><meta name="generator" content="DocBook XSL Stylesheets V1.73.2"><link rel="start" href="index.html" title="GDK Reference Manual"><link rel="up" href="reference.html" title="API Reference"><link rel="prev" href="gdk-Event-Structures.html" title="Event Structures"><link rel="next" href="gdk-Selections.html" title="Selections"><meta name="generator" content="GTK-Doc V1.9 (XML mode)"><link rel="stylesheet" href="style.css" type="text/css"><link rel="reference" href="reference.html" title="API Reference"><link rel="index" href="ix01.html" title="Index"><link rel="index" href="ix02.html" title="Index of deprecated symbols"><link rel="index" href="ix03.html" title="Index of new symbols in 2.2"><link rel="index" href="ix04.html" title="Index of new symbols in 2.4"><link rel="index" href="ix05.html" title="Index of new symbols in 2.6"><link rel="index" href="ix06.html" title="Index of new symbols in 2.8"><link rel="index" href="ix07.html" title="Index of new symbols in 2.10"><link rel="index" href="ix08.html" title="Index of new symbols in 2.12"></head><body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"><table class="navigation" id="top" width="100%" summary="Navigation header" cellpadding="2" cellspacing="2"><tr valign="middle"><td><a accesskey="p" href="gdk-Event-Structures.html"><img src="left.png" width="24" height="24" border="0" alt="Prev"></a></td><td><a accesskey="u" href="reference.html"><img src="up.png" width="24" height="24" border="0" alt="Up"></a></td><td><a accesskey="h" href="index.html"><img src="home.png" width="24" height="24" border="0" alt="Home"></a></td><th width="100%" align="center">GDK Reference Manual</th><td><a accesskey="n" href="gdk-Selections.html"><img src="right.png" width="24" height="24" border="0" alt="Next"></a></td></tr><tr><td colspan="5" class="shortcuts"><nobr><a href="#id3251831" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id3252449" class="shortcut">Description</a>                  &#160;|&#160;                  <a href="#id3252386" class="shortcut">Object Hierarchy</a>                  &#160;|&#160;                  <a href="#id3252411" class="shortcut">Signals</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="gdk-Keyboard-Handling"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3251831"></a><span class="refentrytitle">Key Values</span></h2><p>Key Values &#8212; Functions for manipulating keyboard codes</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><a name="GdkKeymap"></a><pre class="synopsis">#include &lt;gdk/gdk.h&gt;                    <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap-struct">GdkKeymap</a>;                    <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey">GdkKeymapKey</a>;<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a>*          <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-default">gdk_keymap_get_default</a>              (void);<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a>*          <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-for-display">gdk_keymap_get_for_display</a>          (<a class="link" href="GdkDisplay.html" title="GdkDisplay">GdkDisplay</a> *display);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a>               <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-lookup-key">gdk_keymap_lookup_key</a>               (<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);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state">gdk_keymap_translate_keyboard_state</a> (<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);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-entries-for-keyval">gdk_keymap_get_entries_for_keyval</a>   (<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);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-entries-for-keycode">gdk_keymap_get_entries_for_keycode</a>  (<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-Keyboard-Handling.html#GdkKeymapKey">GdkKeymapKey</a> **keys,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> **keyvals,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a> *n_entries);<ahref="/usr/share/gtk-doc/html/pango/pango-Text-Processing.html#PangoDirection">PangoDirection</a>      <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-direction">gdk_keymap_get_direction</a>            (<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a> *keymap);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-have-bidi-layouts">gdk_keymap_have_bidi_layouts</a>        (<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap">GdkKeymap</a> *keymap);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>*              <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-name">gdk_keyval_name</a>                     (<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#guint">guint</a>               <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-from-name">gdk_keyval_from_name</a>                (const <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a> *keyval_name);void                <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-convert-case">gdk_keyval_convert_case</a>             (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> symbol,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> *lower,                                                         <ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a> *upper);<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a>               <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-upper">gdk_keyval_to_upper</a>                 (<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#guint">guint</a>               <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-lower">gdk_keyval_to_lower</a>                 (<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#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-is-upper">gdk_keyval_is_upper</a>                 (<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#gboolean">gboolean</a>            <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-is-lower">gdk_keyval_is_lower</a>                 (<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#guint32">guint32</a>             <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-unicode">gdk_keyval_to_unicode</a>               (<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#guint">guint</a>               <a class="link" href="gdk-Keyboard-Handling.html#gdk-unicode-to-keyval">gdk_unicode_to_keyval</a>               (<ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a> wc);</pre></div><div class="refsect1" lang="en"><a name="id3252386"></a><h2>Object Hierarchy</h2><pre class="synopsis">  <ahref="/usr/share/gtk-doc/html/gobject/gobject-The-Base-Object-Type.html#GObject">GObject</a>   +----GdkKeymap</pre></div><div class="refsect1" lang="en"><a name="id3252411"></a><h2>Signals</h2><pre class="synopsis">  "<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap-direction-changed">direction-changed</a>"                              : Run Last  "<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap-keys-changed">keys-changed</a>"                                   : Run Last</pre></div><div class="refsect1" lang="en"><a name="id3252449"></a><h2>Description</h2><p>Key values are the codes which are sent whenever a key is pressed or released.They appear in the <em class="structfield"><code>keyval</code></em> field of the<a class="link" href="gdk-Event-Structures.html#GdkEventKey"><span class="type">GdkEventKey</span></a> structure, which is passed to signal handlers for the"key-press-event" and "key-release-event" signals.The complete list of key values can be found in the <code class="filename">&lt;gdk/gdkkeysyms.h&gt;</code>header file. <code class="filename">&lt;gdk/gdkkeysyms.h&gt;</code> is not included in <code class="filename">&lt;gtk/gtk.h&gt;</code>, it must be included independently, because the file is quite large.</p><p>Key values can be converted into a string representation using<a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-name"><code class="function">gdk_keyval_name()</code></a>. The reverse function, converting a string to a key value,is provided by <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-from-name"><code class="function">gdk_keyval_from_name()</code></a>.</p><p>The case of key values can be determined using <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-is-upper"><code class="function">gdk_keyval_is_upper()</code></a> and<a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-is-lower"><code class="function">gdk_keyval_is_lower()</code></a>. Key values can be converted to upper or lower caseusing <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-upper"><code class="function">gdk_keyval_to_upper()</code></a> and <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-lower"><code class="function">gdk_keyval_to_lower()</code></a>.</p><p>When it makes sense, key values can be converted to and from Unicode characters with <a class="link" href="gdk-Keyboard-Handling.html#gdk-keyval-to-unicode"><code class="function">gdk_keyval_to_unicode()</code></a> and <a class="link" href="gdk-Keyboard-Handling.html#gdk-unicode-to-keyval"><code class="function">gdk_unicode_to_keyval()</code></a>.</p><p>One <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> object exists for each user display. <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-default"><code class="function">gdk_keymap_get_default()</code></a> returns the <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymap"><span class="type">GdkKeymap</span></a> for the default display; to obtain keymaps for other displays, use <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-get-for-display"><code class="function">gdk_keymap_get_for_display()</code></a>. A keymapis a mapping from <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey"><span class="type">GdkKeymapKey</span></a> to key values. You can think of a <a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey"><span class="type">GdkKeymapKey</span></a>as a representation of a symbol printed on a physical keyboard key. That is, itcontains three pieces of information. First, it contains the hardware keycode;this is an identifying number for a physical key. Second, it contains the<em class="firstterm">level</em> of the key. The level indicates which symbol on thekey will be used, in a vertical direction. So on a standard US keyboard, the keywith the number "1" on it also has the exclamation point ("!") character onit. The level indicates whether to use the "1" or the "!" symbol.  The letterkeys are considered to have a lowercase letter at level 0, and an uppercaseletter at level 1, though only the uppercase letter is printed.  Third, the<a class="link" href="gdk-Keyboard-Handling.html#GdkKeymapKey"><span class="type">GdkKeymapKey</span></a> contains a group; groups are not used on standard US keyboards,but are used in many other countries. On a keyboard with groups, there can be 3or 4 symbols printed on a single key. The group indicates movement in ahorizontal direction. Usually groups are used for two different languages.  Ingroup 0, a key might have two English characters, and in group 1 it might havetwo Hebrew characters. The Hebrew characters will be printed on the key next tothe English characters.</p><p>In order to use a keymap to interpret a key event, it's necessary to firstconvert the keyboard state into an effective group and level. This is done via aset of rules that varies widely according to type of keyboard and userconfiguration. The function <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state"><code class="function">gdk_keymap_translate_keyboard_state()</code></a> accepts akeyboard state -- consisting of hardware keycode pressed, active modifiers, andactive group -- applies the appropriate rules, and returns the group/level to beused to index the keymap, along with the modifiers which did not affect thegroup and level. i.e. it returns "unconsumed modifiers." The keyboard group maydiffer from the effective group used for keymap lookups because some keys don'thave multiple groups - e.g. the Enter key is always in group 0 regardless ofkeyboard state.</p><p>Note that <a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state"><code class="function">gdk_keymap_translate_keyboard_state()</code></a> also returns the keyval, i.e. itgoes ahead and performs the keymap lookup in addition to telling you whicheffective group/level values were used for the lookup.  <a class="link" href="gdk-Event-Structures.html#GdkEventKey"><span class="type">GdkEventKey</span></a> alreadycontains this keyval, however, so you don't normally need to call<a class="link" href="gdk-Keyboard-Handling.html#gdk-keymap-translate-keyboard-state"><code class="function">gdk_keymap_translate_keyboard_state()</code></a> just to get the keyval.</p></div><div class="refsect1" lang="en"><a name="id3252760"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3252770"></a><h3><a name="GdkKeymap-struct"></a>GdkKeymap</h3><a class="indexterm" name="id3252784"></a><pre class="programlisting">typedef struct _GdkKeymap GdkKeymap;</pre><p>A <span class="structname">GdkKeymap</span> defines the translation from keyboard state(including a hardware key, a modifier mask, and active keyboard group)to a keyval. This translation has two phases. The first phase isto determine the effective keyboard group and level for the keyboardstate; the second phase is to look up the keycode/group/level tripletin the keymap and see what keyval it corresponds to.</p></div><hr><div class="refsect2" lang="en"><a name="id3252808"></a><h3><a name="GdkKeymapKey"></a>GdkKeymapKey</h3><a class="indexterm" name="id3252821"></a><pre class="programlisting">typedef struct {  guint keycode;  gint  group;  gint  level;} GdkKeymapKey;</pre><p>A <span class="structname">GdkKeymapKey</span> is a hardware key that can be mapped to a keyval.</p><div class="variablelist"><table border="0"><col align="left" valign="top">

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -