Re: Window receiving button-release-event



On Wed, May 30, 2007 at 03:25:12PM +0200, Peter Daum wrote:
I have a dialog that represents some sort of database values.
The dialog has a "save" button, that I would like to enable
only if the dialogs data differs from the stored data.
I wrote an appropriate "is_modified" function that checks this.

Now I am looking for the right event slot to run this function
after every action that might have changed some widget's value.
There is no way to change anything without either a mouse button
or a key press.

And what if someone invents other methods?  (And they already
exist, for instance you can change the contents of entries
with DnD.  And assistive technologies may have other means
too.)

Is the mechanism of the change crucial, or at least
relevant?  No.

You want to know whether the value changed.  Every Gtk+
widget that enables to enter/change values has a signal, or
several signals, emitted when the value changes.  So connect
to these signals and you are done.  In addition, you will
not be checking whether something has changed every time
user interacts with the window in a way that does not change
anything.

I hoped, the following should do the job, without
having to mess with all the single child widgets
...

`Messing with the widgets' is the conceptually correct
approach, whereas what you try is `these thing often occur
together so let's pretend thy are one'.

$self->add_events("button-release-mask");
$self->signal_connect_after("button-release-event", $check_modified);
$self->signal_connect_after("key-release-event", $check_modified);

The key-release part works as intended, but for some reason,
I don't get any button-release event that occurs within a child
widget that is also interested in button-release (i.e. pretty
much everything except frames and labels).

The GTK documentation says about signal_connect_after:
"The handler will be called after the default handler of the signal
instance", so I hoped it should work even when there is another signal
handler installed.

This would be true for non-event handlers.  Once an event
handler returns TRUE the event is considered handled and the
remaining handlers are never run.

Yeti

--
http://gwyddion.net/



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