[fxruby-users] How to iterate an array within an event

chen li chen_li3 at yahoo.com
Mon Jan 5 19:44:41 EST 2009


Hi all,

I have an array and here is what I try to accomplish:

click the @button_next,assign the first element to the radioButton of @radio

click the @button_next again, assign the second element to the same radioButton (overwrite the text or update the text)

and so on, untill all the elements are iterated.


I write the codes as follows. But when I run it I only see the last element 5 on the @radio. I wonder someone can 
explain to me what is going on and help me fix it.


Thanks,

Li


###################
def press_next
	@array=["1","2","3","4","5"]

	@array.each do |e|
	    @button_next.connect(SEL_COMMAND) do
		@radio.text="#{e}"
    	    end
	end
end


      


More information about the fxruby-users mailing list