Re: Beginners question abour events



El dom, 29 de 02 de 2004 a las 18:50, Douglas Phillipson escribiÃ:
Murray Cumming wrote:
On Sun, 2004-02-29 at 17:03, Douglas Phillipson wrote:

I can't seem to find why you return TRUE, or FALSE at the end of an 
event routine like:
[snip]
Here's the gtkmm version of the explanation:
http://www.gtkmm.org/gtkmm2/docs/tutorial/html/apbs06.html


I understand what the difference is between returning TRUE and FALSE in 
a handler now (thankyou for the link).  Now how do you tell which you 
should use?  

The clue is: if you want gtk to continue to proccess the signal return
FALSE. If all the work is done in your callback return TRUE.

That's all: have gtk something to do with the signal once your callback
ends ? Return FALSE and gtk will continue to proccess it. Have gtk
nothing to do with the signal ? Return TRUE and pop this signal out the
queue.

Example code I see like:
[snip]
Why is the expose event returning FALSE?  If this implies something else 
must be done in the event mechanism, what is remaining?  Where might 
this be documented?

Here gtk must continue to proccess the event once the draw is done to
show it. So returning FALSE you let gtk finish the job. 

The button press event seems to be done so it returns TRUE.  Is there 
something else I could do, or the gtk/gdk system would/could do with 
button events if I returned FALSE?

I suposse that not too much :)

But you can check much better how this works with other signals, as the
delete_event

Once gtk gets a delete_event it kills the window or dialog receiving the
signal.

So,

delete_event(){
        return FALSE;
}

... will kill the window, but ...

delete_event(){
        return TRUE;
}

.. will push out the queue the delete_event signal and the window will
not be killed.

This way you can do:

on_window_delete_event(){
        if( everything_is_ok() ){
                return FALSE;
        }else{
                // stop processing the signal
                // I have something to do ...
                return TRUE;
        }
}


Hope this helps :)
-- 
Iago Rubio                http://www.iagorubio.com          
GPGkey pgp.rediris.es id 0x909BD4DD  fingerprint =
D18A B950 5F03 BB9A DD89  AA75 FEDF 1978 909B D4DD
********** iago.rubio(AT)hispalinux.es  **********     
--------------------------------------------------

Attachment: signature.asc
Description: Esta parte del mensaje =?ISO-8859-1?Q?est=E1?= firmada digitalmente



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