# Help with FXDialogBox

**URL:** <https://www.ruby-forum.com/t/help-with-fxdialogbox/87506>\
**Category:** Ruby\
**Created:** [March 3, 2007, 4:49am UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506 "2007-03-03T04:49:09Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 3, 2007, 4:49am UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/1 "2007-03-03T04:49:09Z")

</div>

I want a DialogBox where I can click a button, perform some operation,  
possibly returning a value, and then the DialogBox should close (not  
hide, close). The methods I have tried for this have failed. My  
current setup, which gives me a seg fault, is:

button = FXButton.new(parent, text, icon, nil, nil, 0, . . .)  
button.connect(SEL\_COMMAND) do |sender, sel, data|  
self.download(card)  
self.handle(sender, ID\_ACCEPT, data)  
end

I also tried  
button = FXButton.new(parent, text, icon, nil, self, ID\_ACCEPT . . .)  
button.connect(SEL\_COMMAND) do  
self.download(card)  
end

I can’t get either of these to work. What information am I missing  
here?

Raj

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 3, 2007, 4:55am UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/2 "2007-03-03T04:55:10Z")

</div>

Raj S. wrote:

> 

I fixed a typo in the code

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 3, 2007, 6:11am UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/3 "2007-03-03T06:11:13Z")

</div>

Raj S. wrote:

> > end  
> > Raj  
> > My latest attempt, failure once more, is the following:

FXButton.new(rows[index/CPR], nil , icon, self, ID\_ACCEPT,  
LAYOUT\_FIX\_WIDTH|LAYOUT\_FIX\_HEIGHT|BUTTON\_NORMAL, 0,0, WIDTH,  
HEIGHT) do |button|  
button.connect(SEL\_COMMAND) { self.download(card) }  
end

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 3, 2007, 8:37pm UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/4 "2007-03-03T20:37:41Z")

</div>

> Nobody on this one?  
> Lyle, you around somewhere?

Ok I gave up doing it with a DialogBox and now I’m just using another  
FXMainWindow

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 3, 2007, 7:02pm UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/5 "2007-03-03T19:02:30Z")

</div>

Raj S. wrote:

> > > ```
> > > self.handle(sender, ID_ACCEPT, data)
> > > 
> > > ```

Nobody on this one?  
Lyle, you around somewhere?

---

<div class="post-metadata">

**Author:** ![dorelal](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/3da27b/32.png) [@dorelal](https://www.ruby-forum.com/u/dorelal)\
**Post date:** [March 5, 2007, 6:20am UTC](https://www.ruby-forum.com/t/help-with-fxdialogbox/87506/6 "2007-03-05T06:20:32Z")

</div>

On 2007-03-02 21:48:39 -0600, Raj S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) said:

> I want a DialogBox where I can click a button, perform some operation,  
> possibly returning a value, and then the DialogBox should close (not  
> hide, close). The methods I have tried for this have failed. My  
> current setup, which gives me a seg fault, is:
> 
> button = FXButton.new(parent, text, icon, nil, nil, 0, . . .)  
> button.connect(SEL\_COMMAND) do |sender, sel, data|  
> self.download(card)  
> self.handle(sender, ID\_ACCEPT, data)  
> end

I don’t know what “self” refers to in this context, but for the moment  
I’ll assume that it is the dialog box itself. In that case, you were  
close; the call to FXDialogBox#handle should have looked like this:

dialog\_box.handle(button, FXSEL(SEL\_COMMAND, FXDialogBox::ID\_ACCEPT),  
nil)

Hope this helps,

Lyle

P.S. Please post these questions to the fxruby-users mailing list for a  
quicker response. I’m not able to check ruby-talk nearly as frequently  
(or as thoroughly) as I used to.
