Re: tracking mouse pointer
- From: Paul Pogonyshev <pogonyshev gmx net>
- To: <gtk-app-devel-list gnome org>
- Subject: Re: tracking mouse pointer
- Date: Tue, 30 Dec 2003 17:47:44 +0000
Tom Liu wrote:
This is my test program to handle the motion, the event->state tell you
the key sataus like shift or ctrl.
gboolean butt_motion(GtkWidget *widget, GdkEventMotion *event,
gpointer user_data)
{
printf("buttonmotion:%s,%x\n",user_data,event->state);
int x, y;
GdkModifierType state;
gdk_window_get_pointer (event->window, &x, &y, &state);
return TRUE;
}
This is wonderful, but you should have read my message more attentively.
I didn't say it didn't work completely. I said this:
First of all, i would like it to provide feedback when the window containing
the widget is "popped" (i.e shown, deiconified, or maybe shown together
with its desktop etc.) I tried to make "show", "map" or "enter-notify-event"
callbacks to call gtk_widget_get_pointer() and use its information, but
either that didn't work at all, or the coordinates were wrong. Any ideas?
Another problem is that i use modifier keys (like Shift) to alter the action
performed. This would in turn alter the feedback depending on currently
pressed keys. However, i have to use events like "key-(press|release)-event"
instead of "motion-notify-event" (one can (de)press Shift without touching
his mouse) and those events report "lagged" modifiers. I.e. event structure
for a "key-press-event" for Shift would still claim that Shift is depressed.
Is there some way to get proper modifiers, or do i have to do that by
hands?
Let me rephrase.
1) A window is shown in such a way that the pointer is over my widget. What
signal(s) do i connect to in order to make sure i update visual feedback
properly in such cases? Maybe "visibility-notify-event"? What is it, btw?
I can't see any description in GTK+ reference.
2) The user presses Shift key. Is there a signal i could connect to and receive
modifier flags with GDK_SHIFT_MASK set?
For "key-press-event" it is set only after the event is propagated. I used
this callback for both "key-press-event" and "key-release-event":
static gboolean
gtk_goban_key_event(GtkWidget *widget, GdkEventKey *event)
{
if (event->type == GDK_KEY_PRESS) {
parent_class->key_press_event(widget, event);
g_print("press: %x\n", event->state);
}
else {
parent_class->key_release_event(widget, event);
g_print("release: %x\n", event->state);
}
return FALSE;
}
If i press and release Shift, i get "press: 10", "release: 11". That is,
GDK_SHIFT_MASK is set for _release_ event, while i would certainly like it
the way round.
Paul Pogonyshev
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]