Hi together,
I have problems to create a proper workflow between views.
IndexView should be closed at least.class IndexView : View() {
override val root: BorderPane by fxml("/view/IndexView.fxml", true)
val newView: NewView by inject()
init {
title = "Hello Index View"
}
fun newView() {
// Put some extra data to aboutView by input fields or something
newView.openWindow() // what's the difference to modal?
newView.openModal()
}
}
title, it just keep the old title Hello Index View.class IndexView : View() {
override val root: BorderPane by fxml("/view/IndexView.fxml", true)
val newView: NewView by inject()
init {
title = "Hello Index View"
}
fun newView() {
root.center = newView.root
}
}
Can you help me?
replaceWith(myView::class, someAnimation)
seems really nice. But how could I exchange information like for logins?
Thanks and best regards
Gino
You can actually pass parameters between Views, but it is often more flexible to inject a ViewModel into both views, and simply binding towards those values in the first View. Whenever you do replaceWith to go to the second View, your data is already available to you. Check out the ViewModel in the guide:
https://edvin.gitbooks.io/tornadofx-guide/content/11.%20Editing%20Models%20and%20Validation.html
The difference between openWindow and openModal is that the first will not create a modal window by default, meaning that you can still interact with UI behind it. You can call close() on the IndexView when you open a new window or modal dialog.
You can for sure update the title of the containing View when you replace some parts of it with another, but I suspect you're looking for something like the Workspace for this use case. If I'm mistaken, maybe you can elaborate a little about your use case so I can suggest a better approach? Check out the Workspace here:
https://edvin.gitbooks.io/tornadofx-guide/content/16.%20Workspaces.html
If you just want to change the center node and update the title, you could do something like:
fun newView() {
titleProperty.cleanBind(newView.titleProperty)
root.center = newView.root
}
However, that seems like a hack, so I'm sure we can find a better way to do what you want.
Hi Edvin,
thanks this already helped a lot to understand. :) If something is still unclear for me, I will re-open the issue.
Best regards
Gino
Great! I want to do a "How to create a login screen" video soon, will post the link here :)
Most helpful comment
Great! I want to do a "How to create a login screen" video soon, will post the link here :)