Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HBox "add" should accept an array #85

Open
vpereira opened this issue Nov 7, 2014 · 2 comments
Open

HBox "add" should accept an array #85

vpereira opened this issue Nov 7, 2014 · 2 comments

Comments

@vpereira
Copy link

vpereira commented Nov 7, 2014

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)

@byteit101
Copy link
Member

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

@vpereira
Copy link
Author

vpereira commented Nov 8, 2014

ok, i will try to work on the exts.yaml way, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants