求教gtk鼠标事件

软件和网站开发以及相关技术探讨
回复
Earplayer
帖子: 6
注册时间: 2012-10-15 9:26
系统: Ubuntu12.04

求教gtk鼠标事件

#1

帖子 Earplayer » 2013-07-24 21:31

请问有大神有这个的资料么,关于各种鼠标键盘的操作响应,鼠标左右键单击双击事件等等的......
头像
cjxgm
帖子: 1952
注册时间: 2010-04-23 20:40
系统: Arch Linux
来自: 浙江·杭州
联系:

Re: 求教gtk鼠标事件

#2

帖子 cjxgm » 2013-07-24 21:48

代码: 全选

cat /usr/include/gtk-3.0/gdk/gdkevents.h
比如鼠标:

代码: 全选

/**
 * GdkEventButton:
 * @type: the type of the event (%GDK_BUTTON_PRESS, %GDK_2BUTTON_PRESS,
 *   %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE).
 * @window: the window which received the event.
 * @send_event: %TRUE if the event was sent explicitly (e.g. using
 *   <function>XSendEvent</function>).
 * @time: the time of the event in milliseconds.
 * @x: the x coordinate of the pointer relative to the window.
 * @y: the y coordinate of the pointer relative to the window.
 * @axes: @x, @y translated to the axes of @device, or %NULL if @device is
 *   the mouse.
 * @state: (type GdkModifierType): a bit-mask representing the state of
 *   the modifier keys (e.g. Control, Shift and Alt) and the pointer
 *   buttons. See #GdkModifierType.
 * @button: the button which was pressed or released, numbered from 1 to 5.
 *   Normally button 1 is the left mouse button, 2 is the middle button,
 *   and 3 is the right button. On 2-button mice, the middle button can
 *   often be simulated by pressing both mouse buttons together.
 * @device: the device where the event originated.
 * @x_root: the x coordinate of the pointer relative to the root of the
 *   screen.
 * @y_root: the y coordinate of the pointer relative to the root of the
 *   screen.
 *
 * Used for button press and button release events. The
 * @type field will be one of %GDK_BUTTON_PRESS,
 * %GDK_2BUTTON_PRESS, %GDK_3BUTTON_PRESS or %GDK_BUTTON_RELEASE,
 *
 * Double and triple-clicks result in a sequence of events being received.
 * For double-clicks the order of events will be:
 * <orderedlist>
 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
 * </orderedlist>
 * Note that the first click is received just like a normal
 * button press, while the second click results in a %GDK_2BUTTON_PRESS
 * being received just after the %GDK_BUTTON_PRESS.
 *
 * Triple-clicks are very similar to double-clicks, except that
 * %GDK_3BUTTON_PRESS is inserted after the third click. The order of the
 * events is:
 * <orderedlist>
 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_2BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
 * <listitem><para>%GDK_BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_3BUTTON_PRESS</para></listitem>
 * <listitem><para>%GDK_BUTTON_RELEASE</para></listitem>
 * </orderedlist>
 *
 * For a double click to occur, the second button press must occur within
 * 1/4 of a second of the first. For a triple click to occur, the third
 * button press must also occur within 1/2 second of the first button press.
 */
struct _GdkEventButton
{
  GdkEventType type;
  GdkWindow *window;
  gint8 send_event;
  guint32 time;
  gdouble x;
  gdouble y;
  gdouble *axes;
  guint state;
  guint button;
  GdkDevice *device;
  gdouble x_root, y_root;
};

event->type == GDK_2BUTTON_PRESS 双击
event->type == GDK_3BUTTON_PRESS 三击
event->button 左键或右键
Clanjor Prods. | Develop for Developers. (C++, Lua) | 作曲编曲 | 实时渲染引擎
头像
eexpress
帖子: 58428
注册时间: 2005-08-14 21:55
来自: 长沙

Re: 求教gtk鼠标事件

#3

帖子 eexpress » 2013-07-24 21:50

不如直接看例子。
https://github.com/eexpress/eexp-bin/bl ... ather.vala
各种鼠标操作。
● 鸣学
回复