HBox "add" should accept an array
Hi, I have the following snippet:
require 'jrubyfx'
class AddSubtract < JRubyFX::Application
attr_accessor :count
def initialize
@count = 0
end
def start(stage)
lbl = label("Count: 0")
btn_add = button("Add")
btn_sub = button("Sub")
btn_add.set_on_action { |e| @count+=1; lbl.text = "Count: #{@count}" }
btn_sub.set_on_action { |e| @count-=1; lbl.text = "Count: #{@count}" }
pane = hbox 10
pane.add lbl
pane.add btn_add
pane.add btn_sub
stage.scene = scene(pane,200,75)
stage.title = "Add/Sub"
stage.show
end
end
AddSubtract.launch
I'm not using the DSL, because I feel that I can better manage my variables contexts. However I think the lines:
pane = hbox 10
pane.add lbl
pane.add btn_add
pane.add btn_sub
should accept as well the pane.add [lbl,btn_add,btn_sub]. Does it make sense? if yes, can you guide me, how could I update jrubyfx to support it (in long term, i would like to contribute to the project, so it would be a baby step in this direction)
I would be more in favor or pane.add(lbl,btn_add,btn_sub) as *args instead of array args.
There are several options, such as https://github.com/jruby/jrubyfx/blob/master/lib/jrubyfx/core_ext/exts.yml and https://github.com/jruby/jrubyfx/blob/master/lib/jrubyfx/dsl.rb#L192 or adding it manually to each class. I'm currently thinking all classes that do the add thing should support multi-arguments, which would be a +1 for the exts.yaml way
ok, i will try to work on the exts.yaml way, thanks!