利用GdkEventButton: typedef struct { 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; } GdkEventButton; GdkEventType type; the type of the event (GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS, GDK_3BUTTON_PRESS or GDK_BUTTON_RELEASE).
GdkWindow *window; the window which received the event.
gint8 send_event; TRUE if the event was sent explicitly (e.g. using XSendEvent).
guint32 time; the time of the event in milliseconds.
gdouble x; the x coordinate of the pointer relative to the window.
gdouble y; the y coordinate of the pointer relative to the window.
gdouble *axes; x, y translated to the axes of device, or NULL if device is the mouse.
guint state; a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType.
guint 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.
GdkDevice *device; the device where the event originated.
gdouble x_root; the x coordinate of the pointer relative to the root of the screen.
gdouble y_root; the y coordinate of the pointer relative to the root of the screen.
发布评论
评论(3)
利用GdkEventButton:
typedef struct {
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;
} GdkEventButton;
GdkEventType type;
the type of the event (GDK_BUTTON_PRESS, GDK_2BUTTON_PRESS, GDK_3BUTTON_PRESS or GDK_BUTTON_RELEASE).
GdkWindow *window;
the window which received the event.
gint8 send_event;
TRUE if the event was sent explicitly (e.g. using XSendEvent).
guint32 time;
the time of the event in milliseconds.
gdouble x;
the x coordinate of the pointer relative to the window.
gdouble y;
the y coordinate of the pointer relative to the window.
gdouble *axes;
x, y translated to the axes of device, or NULL if device is the mouse.
guint state;
a bit-mask representing the state of the modifier keys (e.g. Control, Shift and Alt) and the pointer buttons. See GdkModifierType.
guint 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.
GdkDevice *device;
the device where the event originated.
gdouble x_root;
the x coordinate of the pointer relative to the root of the screen.
gdouble y_root;
the y coordinate of the pointer relative to the root of the screen.
具体的查reference,gtk+2.0 tutorial 和gtk+-demo
回复 2# cstdio
图形编程我不太会 不知道可不可以给写个小demo
回复 1# kanhfshiys
如果是qt的话那很简单
QPoint QCursor::pos ()