[fxruby-users] Beginner question: handling FXColorDialog cancellation

Paolo Micossi paolo.micossi at mac.com
Wed Aug 15 09:32:55 EDT 2007


Hello.

As part of my first FXRuby project I'm trying to set up things so  
that the color of some graphic elements gets changed by pressing a  
button.
The button pops up an FXColorDialog and code is supplied to handle  
the change. I test the value returned by FXColorDialog::execute to  
detect cancellation and restore the original color, but it does not  
seem to work.
Here is the relevant code fragment:

		FXButton.new(frame,'Sinusoide',nil,nil,0,LAYOUT_FILL_X| 
BUTTON_NORMAL).connect(SEL_COMMAND) do
			d = FXColorDialog.new(self,'Colore Sinusoide')
			d.rgba = @graph.getPlot('Test Curve').color
			c = d.rgba
			d.connect(SEL_COMMAND) do |sender,sel,ev|
				@graph.getPlot('Test Curve').color = ev
			end
			unless d.execute
				@graph.getPlot('Test Curve').color = c
			end
		end

Before the FXColorDialog is executed I initialize it with the current  
color of the object, and also save it in variable "c" for later  
restore. The dialog shows up with the right initialized color.
The color= setter method of the graphic elements sends update  
messages to the relevant targets, so i can see the color being  
updated on screen all right while I'm choosing inside the dialog.
On dialog exit the color will stay put at the last color chosen in  
the dialog, regardless of pressing 'Accept' or 'Cancel'
Why is it so?

Regards,
Paolo Micossi
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/fxruby-users/attachments/20070815/23807887/attachment.html 


More information about the fxruby-users mailing list