Re: drawing area and button press event

On 12/08/05, Yiannis <odysseus lost gmail com> wrote:
On 12/08/05, Michal Porzuczek <mporzuczek gmail com> wrote:
On 8/12/05, Yiannis <odysseus lost gmail com> wrote:

my callback on the button press event seems not to be called... in
fact I am not sure if a button press event occurs. Find below a simple
program (using glade/libglade) that makes a drawing area and a 2
callbacks... The expose event and the button press event callback.


I'm not 100% sure since I've never used Glade before and I'm not sure
if it takes care of it, but I know with GTK  you have to include:

gtk_widget_set_events (Drawing_Area, GDK_EXPOSURE_MASK
                        | GDK_LEAVE_NOTIFY_MASK
                        | GDK_BUTTON_PRESS_MASK);

Cheers, this missing bit on my code seems to be the problem, as if you
take it out from the original scribble tutorial program there are no
"responses" to button press events. However, firstly I never
understood what is meant by  the following (taken from the gtk

"As for other signals, to determine what happens when an event occurs
we call gtk_signal_connect(). But we also need let GTK know which
events we want to be notified about. To do this, we call the function:

Doesn't gtk sends these events??? And what these have to do with the
button press event?

Anyway including this on my code gives me the following error:
(md:9727): GLib-GObject-CRITICAL **: g_object_unref: assertion
`G_IS_OBJECT (object)' failed

which if I recall well it has to do with when you call
gtk_widget_set_events, I think it has to go before showing the
toplevel widget.... but in my case the only thing I can do is hide the
window and gtk_widget_show after setting the events... which I tried
and still gives the same error.

To kind of close the matter. As it is written in the gtk doc:
"This function (gtk_widget_set_events()) must be called while a widget
is unrealized. Consider gtk_widget_add_events() for widgets that are
already realized"

Upon calling glade_xml_new all widgets maybe are realised. It seems
that  the gtk_widget_add_events() does the job. Although I am still
getting this annoying error message not understanding why:
GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT
(object)' failed

-- Yiannis

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]