Re: Send mouse button press event to widget??
David Nečas (Yeti)-2 wrote: On Thu, Aug 30, 2007 at 05:24:21AM -0700, eminemence wrote: I am creating a virtual cursor on a web page and want to simulate the left click of the mouse button when the user presses the enter button. So I tried even using the gdk_event_put on the global window itself,assuming the event would find it's way to the control under the cursor. The gdk_event_put has not been successful,so what is the way to achieve this? I don't recall a working example now (the Gtk+ source code has some though), but: - create the event with gdk_event_new() - fill the fields - cursor position (in GdkWindow coordinates) can be obtained with gdk_window_get_pointer() - window fields have to be g_object_ref()ed IIRC as something unrefs them later - send_event should be TRUE - other information can be obtained from the original event or other means - send the event with gtk_widget_event() - free event - remember if you send a button presses and no button releases, widgets can get confused Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list Thanks for the replies. I was successful in sending an mouse press event to the widget. But I have noticed only the GDK_BUTTON_PRESS is sent to the button. And GDK_BUTTON_RELEASE is not sent at all.So as of now the button is just getting depressed and is not released,so now how can I make the release action to occur? I have already tried sending the GDK_BUTTON_RELEASE event immediately after the PRESS event,like this: gtk_widget_event(GTK_WIDGET(gPage),eButtonPress); gtk_widget_event(GTK_WIDGET(gPage),eButtonRelease); But the release event is getting lost somewhere!!! Also I have even tried using gtk_main_do_event. -- View this message in context: http://www.nabble.com/Send-mouse-button-press-event-to-widget---tf4353330.html#a12459349 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Send mouse button press event to widget??
Hi All, Am a newbie to linux gtk programming.I want trying to send the mouse button press event to my widget and so I tried this code: Code: ### guint signalid = g_signal_new(button_press_event, G_TYPE_FUNDAMENTAL(0), G_SIGNAL_RUN_FIRST, NULL, NULL, NULL, NULL, G_TYPE_NONE,0); g_signal_emit(GTK_OBJECT(gPage),signalid,0); ### Can someone tell me what is wrong out there? Thanks in advance. --eminemence. -- View this message in context: http://www.nabble.com/Send-mouse-button-press-event-to-widget---tf4353330.html#a12404489 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Send mouse button press event to widget??
I am creating a virtual cursor on a web page and want to simulate the left click of the mouse button when the user presses the enter button. So I tried even using the gdk_event_put on the global window itself,assuming the event would find it's way to the control under the cursor. The gdk_event_put has not been successful,so what is the way to achieve this? --Mayur. David Nečas (Yeti)-2 wrote: On Thu, Aug 30, 2007 at 03:37:04AM -0700, eminemence wrote: Am a newbie to linux gtk programming.I want trying to send the mouse button press event to my widget and so I tried this code: Code: ### guint signalid = g_signal_new(button_press_event, G_TYPE_FUNDAMENTAL(0), G_SIGNAL_RUN_FIRST, NULL, NULL, NULL, NULL, G_TYPE_NONE,0); g_signal_emit(GTK_OBJECT(gPage),signalid,0); ### Can someone tell me what is wrong out there? Several things: 1) g_signal_new() creates (registers) a new signal for a class -- a new `type' of signal. This is not what you want, you want to emit an existing signal button-press-event (though see below). 2) The g_signal_new() arguments are bogus, for instance if you actually registered a new signal for GtkWidget, you would pass GTK_TYPE_WIDGET, not G_TYPE_FUNDAMENTAL(0) (which makes little sense) as the instance type, but since you don't want to register a new signal, I will leave this. 3) Signal is emitted with g_signal_emit() -- or rather g_signal_emit_by_name() if done by code outside the class: g_signal_emit_by_name(button, clicked); (in practice a method to emit this signal is defined for most signal one wants to emit in application code, so you would use gtk_button_clicked() here). 4) Events are special and sending events is done by a different functions than normal signal emission: gtk_main_do_event() or gtk_widget_event(). First you synthetize the event by creating it with gdk_event_new() and filling the fields, then send it and free with gdk_event_free(). Now, forget all this because in almost all cases you think you need to send a synthetic an event to a widget, a better solution exists. So, tell what you want to achieve. Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list -- View this message in context: http://www.nabble.com/Send-mouse-button-press-event-to-widget---tf4353330.html#a12406136 Sent from the Gtk+ - Apps Dev mailing list archive at Nabble.com. ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list
Re: Send mouse button press event to widget??
On Thu, Aug 30, 2007 at 05:24:21AM -0700, eminemence wrote: I am creating a virtual cursor on a web page and want to simulate the left click of the mouse button when the user presses the enter button. So I tried even using the gdk_event_put on the global window itself,assuming the event would find it's way to the control under the cursor. The gdk_event_put has not been successful,so what is the way to achieve this? I don't recall a working example now (the Gtk+ source code has some though), but: - create the event with gdk_event_new() - fill the fields - cursor position (in GdkWindow coordinates) can be obtained with gdk_window_get_pointer() - window fields have to be g_object_ref()ed IIRC as something unrefs them later - send_event should be TRUE - other information can be obtained from the original event or other means - send the event with gtk_widget_event() - free event - remember if you send a button presses and no button releases, widgets can get confused Yeti -- http://gwyddion.net/ ___ gtk-app-devel-list mailing list gtk-app-devel-list@gnome.org http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list