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

📄 gdk-event-structures.html

📁 最新gtk中文资料集
💻 HTML
📖 第 1 页 / 共 5 页
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"><title>Event Structures</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-Events.html" title="Events"><link rel="next" href="gdk-Keyboard-Handling.html" title="Key Values"><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-Events.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-Keyboard-Handling.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="#id3238272" class="shortcut">Top</a>                  &#160;|&#160;                  <a href="#id3238539" class="shortcut">Description</a></nobr></td></tr></table><div class="refentry" lang="en"><a name="gdk-Event-Structures"></a><div class="titlepage"></div><div class="refnamediv"><table width="100%"><tr><td valign="top"><h2><a name="id3238272"></a><span class="refentrytitle">Event Structures</span></h2><p>Event Structures &#8212; Data structures specific to each type of event</p></td><td valign="top" align="right"></td></tr></table></div><div class="refsynopsisdiv"><h2>Synopsis</h2><pre class="synopsis">#include &lt;gdk/gdk.h&gt;union               <a class="link" href="gdk-Event-Structures.html#GdkEvent">GdkEvent</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventAny">GdkEventAny</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventKey">GdkEventKey</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventButton">GdkEventButton</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventScroll">GdkEventScroll</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventMotion">GdkEventMotion</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventExpose">GdkEventExpose</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventVisibility">GdkEventVisibility</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventCrossing">GdkEventCrossing</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventFocus">GdkEventFocus</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventConfigure">GdkEventConfigure</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventProperty">GdkEventProperty</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventSelection">GdkEventSelection</a>;typedef             <a class="link" href="gdk-Event-Structures.html#GdkNativeWindow">GdkNativeWindow</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventDND">GdkEventDND</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventProximity">GdkEventProximity</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventClient">GdkEventClient</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventNoExpose">GdkEventNoExpose</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventWindowState">GdkEventWindowState</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventSetting">GdkEventSetting</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventOwnerChange">GdkEventOwnerChange</a>;                    <a class="link" href="gdk-Event-Structures.html#GdkEventGrabBroken">GdkEventGrabBroken</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkScrollDirection">GdkScrollDirection</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkVisibilityState">GdkVisibilityState</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkCrossingMode">GdkCrossingMode</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkNotifyType">GdkNotifyType</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkPropertyState">GdkPropertyState</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkWindowState">GdkWindowState</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkSettingAction">GdkSettingAction</a>;enum                <a class="link" href="gdk-Event-Structures.html#GdkOwnerChange">GdkOwnerChange</a>;</pre></div><div class="refsect1" lang="en"><a name="id3238539"></a><h2>Description</h2><p>The event structs contain data specific to each type of event in GDK.</p><div class="note" style="margin-left: 0.5in; margin-right: 0.5in;"><h3 class="title">Note</h3><p>A common mistake is to forget to set the event mask of a widget so that therequired events are received. See <ahref="/usr/share/gtk-doc/html/gtk/GtkWidget.html#gtk-widget-set-events"><code class="function">gtk_widget_set_events()</code></a>.</p></div></div><div class="refsect1" lang="en"><a name="id3238575"></a><h2>Details</h2><div class="refsect2" lang="en"><a name="id3238586"></a><h3><a name="GdkEvent"></a>union GdkEvent</h3><a class="indexterm" name="id3238598"></a><pre class="programlisting">union GdkEvent{  GdkEventType		    type;  GdkEventAny		    any;  GdkEventExpose	    expose;  GdkEventNoExpose	    no_expose;  GdkEventVisibility	    visibility;  GdkEventMotion	    motion;  GdkEventButton	    button;  GdkEventScroll            scroll;  GdkEventKey		    key;  GdkEventCrossing	    crossing;  GdkEventFocus		    focus_change;  GdkEventConfigure	    configure;  GdkEventProperty	    property;  GdkEventSelection	    selection;  GdkEventOwnerChange  	    owner_change;  GdkEventProximity	    proximity;  GdkEventClient	    client;  GdkEventDND               dnd;  GdkEventWindowState       window_state;  GdkEventSetting           setting;  GdkEventGrabBroken        grab_broken;};</pre><p>The <a class="link" href="gdk-Event-Structures.html#GdkEvent"><span class="type">GdkEvent</span></a> struct contains a union of all of the event structs,and allows access to the data fields in a number of ways.</p><p>The event type is always the first field in all of the event structs, andcan always be accessed with the following code, no matter what type of eventit is:</p><div class="informalexample"><pre class="programlisting">  GdkEvent *event;    GdkEventType type;  type = event-&gt;type;</pre></div><p></p><p>To access other fields of the event structs, the pointer to the event can becast to the appropriate event struct pointer, or the union member name can beused. For example if the event type is <a class="link" href="gdk-Events.html#GDK-BUTTON-PRESS:CAPS"><code class="literal">GDK_BUTTON_PRESS</code></a> then the x coordinateof the button press can be accessed with:</p><div class="informalexample"><pre class="programlisting">  GdkEvent *event;    gdouble x;  x = ((GdkEventButton*)event)-&gt;x;</pre></div><p>or:</p><div class="informalexample"><pre class="programlisting">  GdkEvent *event;    gdouble x;  x = event-&gt;button.x;</pre></div><p></p></div><hr><div class="refsect2" lang="en"><a name="id3238702"></a><h3><a name="GdkEventAny"></a>GdkEventAny</h3><a class="indexterm" name="id3238714"></a><pre class="programlisting">typedef struct {  GdkEventType type;  GdkWindow *window;  gint8 send_event;} GdkEventAny;</pre><p>Contains the fields which are common to all event structs.Any event pointer can safely be cast to a pointer to a <a class="link" href="gdk-Event-Structures.html#GdkEventAny"><span class="type">GdkEventAny</span></a> to accessthese fields.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a class="link" href="gdk-Events.html#GdkEventType">GdkEventType</a>&#160;<em class="structfield"><code>type</code></em>;</span></p></td><td>the type of the event.</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Windows.html#GdkWindow">GdkWindow</a>&#160;*<em class="structfield"><code>window</code></em>;</span></p></td><td>the window which received the event.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint8">gint8</a>&#160;<em class="structfield"><code>send_event</code></em>;</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the event was sent explicitly (e.g. using <code class="function">XSendEvent</code>).</td></tr></tbody></table></div></div><hr><div class="refsect2" lang="en"><a name="id3238823"></a><h3><a name="GdkEventKey"></a>GdkEventKey</h3><a class="indexterm" name="id3238835"></a><pre class="programlisting">typedef struct {  GdkEventType type;  GdkWindow *window;  gint8 send_event;  guint32 time;  guint state;  guint keyval;  gint length;  gchar *string;  guint16 hardware_keycode;  guint8 group;  guint is_modifier : 1;} GdkEventKey;</pre><p>Describes a key press or key release event.</p><div class="variablelist"><table border="0"><col align="left" valign="top"><tbody><tr><td><p><span class="term"><a class="link" href="gdk-Events.html#GdkEventType">GdkEventType</a>&#160;<em class="structfield"><code>type</code></em>;</span></p></td><td>the type of the event (<a class="link" href="gdk-Events.html#GDK-KEY-PRESS:CAPS"><code class="literal">GDK_KEY_PRESS</code></a> or <a class="link" href="gdk-Events.html#GDK-KEY-RELEASE:CAPS"><code class="literal">GDK_KEY_RELEASE</code></a>).</td></tr><tr><td><p><span class="term"><a class="link" href="gdk-Windows.html#GdkWindow">GdkWindow</a>&#160;*<em class="structfield"><code>window</code></em>;</span></p></td><td>the window which received the event.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint8">gint8</a>&#160;<em class="structfield"><code>send_event</code></em>;</span></p></td><td><ahref="/usr/share/gtk-doc/html/glib/glib-Standard-Macros.html#TRUE:CAPS"><code class="literal">TRUE</code></a> if the event was sent explicitly (e.g. using <code class="function">XSendEvent</code>).</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint32">guint32</a>&#160;<em class="structfield"><code>time</code></em>;</span></p></td><td>the time of the event in milliseconds.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a>&#160;<em class="structfield"><code>state</code></em>;</span></p></td><td>a bit-mask representing the state of the modifier keys (e.g. Control,Shift and Alt) and the pointer buttons. See <a class="link" href="gdk-Windows.html#GdkModifierType"><span class="type">GdkModifierType</span></a>.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#guint">guint</a>&#160;<em class="structfield"><code>keyval</code></em>;</span></p></td><td>the key that was pressed or released. See the <code class="filename">&lt;gdk/gdkkeysyms.h&gt;</code>header file for a complete list of GDK key codes.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gint">gint</a>&#160;<em class="structfield"><code>length</code></em>;</span></p></td><td>the length of <em class="parameter"><code>string</code></em>.</td></tr><tr><td><p><span class="term"><ahref="/usr/share/gtk-doc/html/glib/glib-Basic-Types.html#gchar">gchar</a>&#160;*<em class="structfield"><code>string</code></em>;</span></p></td><td>a string containing the an approximation of the text thatwould result from this keypress. The only correct way to handle textinput of text is using input methods (see <ahref="/usr/share/gtk-doc/html/gtk/GtkIMContext.html"><span class="type">GtkIMContext</span></a>), so thisfield is deprecated and should never be used.(<a class="link" href="gdk-Keyboard-Handling.html#gdk-unicode-to-keyval"><code class="function">gdk_unicode_to_keyval()</code></a> provides a non-deprecated way of gettingan approximate translation for a key.) The string is encoded in the encodingof the current locale (Note: this for backwards compatibility:strings in GTK+ and GDK are typically in UTF-8.) and NUL-terminated.In some cases, the translation of the key code will be a singleNUL byte, in which case looking at <em class="parameter"><code>length</code></em> is necessary to distinguish

⌨️ 快捷键说明

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