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

Need more documentation for controller functions #122

Open
ohkio opened this issue Feb 27, 2018 · 1 comment
Open

Need more documentation for controller functions #122

ohkio opened this issue Feb 27, 2018 · 1 comment

Comments

@ohkio
Copy link

ohkio commented Feb 27, 2018

I've run into a situation where I want to create a new window from within a controller and set the current window as the parent to the new window. I feel like I have most of the steps except how to set the owner and grab the window reference of the current controller. What I have is:
new_stage.init_owner = stage.get_window
I noticed in the code that the stage and scene accessors in controller is only a writer and not a reader. How does one get the reference of these? I'm having trouble figuring this out with current documentation.

@byteit101
Copy link
Member

JavaFX is weird like that. You can either use the java style, from an injected, found, or passed in object: https://stackoverflow.com/questions/26060859/javafx-getting-scene-from-a-controller
Or using the instance varables exposed in a more ruby style

Modifying the fxml sample:

  on :click_purple do
    puts "Clicked Purple"
 p @scene
 p @stage   
p    find('#rootAnchorPane').scene
p    find('#rootAnchorPane').scene.window
  end

Produces:

Clicked Purple
#<Java::JavafxScene::Scene:0x7143a8d8>
#<Java::JavafxStage::Stage:0x2b024e3d>
#<Java::JavafxScene::Scene:0x7143a8d8>
#<Java::JavafxStage::Stage:0x2b024e3d>

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