# How respond to more than one click on the same dialog button

**URL:** <https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967>\
**Category:** Ruby-Gnome 2\
**Created:** [January 23, 2008, 9:23pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967 "2008-01-23T21:23:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 23, 2008, 9:23pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/1 "2008-01-23T21:23:49Z")

</div>

The second time that clicked on one dialog button not response.  
I need process a bucle (more than one time) os signals from  
a Dialog button, “SAVE” for example. In the case of a error may be.  
Can i do with a “Dialog” or i have to use a “Window”

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 23, 2008, 9:40pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/2 "2008-01-23T21:40:32Z")

</div>

On Wed, Jan 23, 2008 at 09:23:49PM +0100, Mil L. wrote:

> The second time that clicked on one dialog button not response.  
> I need process a bucle (more than one time) os signals from  
> a Dialog button, “SAVE” for example. In the case of a error may be.  
> Can i do with a “Dialog” or i have to use a “Window”

Hi Mil,

Your post is a little hard to follow 😉  
But it seems you just want to be able to click on a dialog button  
multiple times?  
If yes, you just have to connect to the ‘response’ signal of Gtk::Dialog  
instead of calling  
the run() method, which destroys the window after the first response.

There’s an example at  
[http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ADialog](http://ruby-gnome2.sourceforge.jp/hiki.cgi?Gtk%3A%3ADialog)

Also, if you want the dialog to be modal, you have to set it explicitly  
with  
set\_modal(true). run() also does this automatically.

Cheers,  
Markus

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 24, 2008, 2:12pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/3 "2008-01-24T14:12:45Z")

</div>

First Excuseme by the text, I am Ecuadorian and my english  
is very bay, ‘like Vista’, je je je …

Thanks very very very much Markus (where are yu from) by your response  
help me much  
, You understand efectively my question.

Before your response i am thinking may use response,  
now you confirm, and i learne some things.

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 25, 2008, 1:06pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/4 "2008-01-25T13:06:43Z")

</div>

On Thu, Jan 24, 2008 at 02:12:45PM +0100, Mil L. wrote:

> First Excuseme by the text, I am Ecuadorian and my english  
> is very bay, ‘like Vista’, je je je …
> 
> Thanks very very very much Markus (where are yu from) by your response  
> help me much  
> , You understand efectively my question.

Absolutely no problem, I’m glad to help you 😉

Cheers,  
Markus (from Switzerland)

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 25, 2008, 5:35pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/5 "2008-01-25T17:35:39Z")

</div>

Ups, i can tell you that i intent solve coding  
de response but i don’t know how do it.

I probe :

class MyDialogo \< Gtk::Dialog  
…  
def initialize  
…  
self.signal\_connect( Gtk::DIalog.RESPONSE\_OK ){

# my code, but no function

}  
…  
end

I read in the API that dialog.response is to emit signal,  
not for process the signal

help me

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 26, 2008, 6:04pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/6 "2008-01-26T18:04:54Z")

</div>

Hi

Take a look at the Gtk::Dialog signals. There is only the “response” and  
the “close” signal. So your signal connection handler has to look like:

self.signal\_connect(‘response’) do |dialog, response\_id|

# handle the response\_id

if response\_id == Gtk::Dialog::RESPONSE\_OK

# do something

end  
end

Cheers, detlef

Am Freitag, den 25.01.2008, 17:35 +0100 schrieb Mil L.:

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 31, 2008, 1:58pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/7 "2008-01-31T13:58:09Z")

</div>

Thanks you.

Its really work.

But i question why the Gnome2 API docs not show:  
signal\_connect(‘response’) do |dialog, response\_id| …  
(I not yet understand this constructions in ruby)  
and only show:  
response(‘response’)

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 31, 2008, 5:48pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/8 "2008-01-31T17:48:28Z")

</div>

Hi,

you are looking at the methodes and with

response(‘response’)

you create a synthetic response signal. Go down the page to the signals  
and you will find:

Signals  
close: self (Run last / Action)  
\* self: Gtk::Dialog  
response: self, response\_id (Run last)  
Emitted when an action widget is clicked, the dialog receives a  
delete event, or the application programmer calls  
Gtk::Dialog#response. On a delete event, the response ID is  
Gtk::Dialog::RESPONSE\_NONE. Otherwise, it depends on which  
action widget was clicked.  
\* self: Gtk::Dialog  
\* response\_id: the response\_id

Am Donnerstag, den 31.01.2008, 13:58 +0100 schrieb Mil L.:

---

<div class="post-metadata">

**Author:** ![1000tonlab](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/1/41988e/32.png) [@1000tonlab](https://www.ruby-forum.com/u/1000tonlab)\
**Post date:** [January 26, 2008, 5:48pm UTC](https://www.ruby-forum.com/t/how-respond-to-more-than-one-click-on-the-same-dialog-button/126967/9 "2008-01-26T17:48:34Z")

</div>

> Gtk::DIalog.RESPONSE\_OK

Hmm are you sure that this Constant is right?  
DIalog seems a bit weird.
