[fxruby-users] Dynamic generation of a (sub) layout

Armin Armbruster aarmbruster at ndigital.com
Fri Nov 21 23:34:11 EST 2008


Hi again,

after digging a bit deeper I found the missing link here:
http://www.nabble.com/deleting-children-and-then-adding-new-ones-to14247201.html#a14256259

The problem was that I didn't call create on the newly created buttons.

I've modified my code as shown below and this seems to work.
Note however that I had to add an additional variable @windowIsLive that's
initialized to false at the start and gets set to true after the show
command in my window-class's create function. Is there a more elegant way to
handle this (for example by querying the @selectUVFrame's status)?

Thanks,
Armin

def generateUVSelectors
	@selectUVFrame.each_child{|c| @selectUVFrame.removeChild(c)}

	b1 = FXButton.new(@selectUVFrame, "&Clear All", nil, nil, 0,)
        b1.connect(SEL_COMMAND){
	  @selectedUVs.each{|cb| cb.setCheck(false)}
	   drawScene
	 }
         b1.create if @windowIsLive


	b2 = FXButton.new(@selectUVFrame, "&Set All", nil, nil, 0)
        b2.connect(SEL_COMMAND){
	  @selectedUVs.each{|cb| cb.setCheck(true)}
	   drawScene
	 }
        b2.create if @windowIsLive


	selectMatrix = FXMatrix.new(@selectUVFrame, 4, MATRIX_BY_COLUMNS)
        selectMatrix.create if @windowIsLive

	@selectedUVs = []

	uvs.length.times{|i|
		@selectedUVs << FXCheckButton.new(selectMatrix, i.to_s, nil, 0){ |cb|
			cb.setCheck(true)
		}
		@selectedUVs[-1].connect(SEL_COMMAND, method(:onSelectUV))
                @selectedUVs[-1].create if @windowIsLive
	}
	
    @selectUVFrame.recalc
end


-- 
View this message in context: http://www.nabble.com/Dynamic-generation-of-a-%28sub%29-layout-tp20630230p20633412.html
Sent from the FXRuby Users mailing list archive at Nabble.com.



More information about the fxruby-users mailing list