tornadofx
tornadofx copied to clipboard
View dissapear when replacedWith on Win
Hello, I'm a tornadFx begginer, so I might be doing something wrong. I have a menu view which consists of two View in borderpane. One is always present and other is changed depending on menu selection. Everything works great on Linux, but when I package for Windows left part of menu dissapears on replaceWith call. Am I doing something wrong? Thanks in advance!
Main menu:
class MenuView : View("Sodabase"){
private val menu: ButtonMenu by inject()
private val itemDBPreview: ItemDatabaseView by inject()
override val root = borderpane{
left=menu.root
center=itemDBPreview.root
}
}
class ButtonMenu : View(){
override val root = borderpane {
addClass(MyStylesheet.menu)
center {
vbox (10,Pos.BASELINE_CENTER){
label("Menu"){
addClass(MyStylesheet.menuLabel)
}
button("Add item"){
action {
replaceWith(ItemImportView::class,ViewTransition.Wipe(0.5.seconds, ViewTransition.Direction.RIGHT))
}
}
button("Withdraw item"){
action {
replaceWith(ItemWithdrawalView::class,ViewTransition.Wipe(0.5.seconds, ViewTransition.Direction.RIGHT))
}
}
button("Add user"){
action{
replaceWith(UserAdditionView::class,ViewTransition.Wipe(0.5.seconds, ViewTransition.Direction.RIGHT))
}
}
}
}
bottom {
hbox (10,Pos.BASELINE_CENTER){
button("Exit") {
action {
UserController.saveChanges()
ItemController.saveChanges()
close()
}
}
}
}
}
}
class ItemDatabaseView: View() {
override val root = tableview(CItemDatabase.getData().asObservable()) {
addClass(MyStylesheet.itemTable)
readonlyColumn("ID", CItem::ID)
readonlyColumn("Name", CItem::name)
readonlyColumn("Friends price", CItem::price)
readonlyColumn("Others price", CItem::otherPrice)
readonlyColumn("Quantity", CItem::quantity)
}
}
Other View:
class ItemImportView :View("Sodabase - Input item") {
private var itemName = SimpleStringProperty()
private var itemPrice = SimpleIntegerProperty()
private var otherPrice = SimpleIntegerProperty()
private var itemQuantity = SimpleIntegerProperty()
override val root = form{
fieldset ("Add item", labelPosition = Orientation.VERTICAL){
field("Item name") {
textfield(itemName)
}
field("Item price") {
textfield(itemPrice){
filterInput { it.controlNewText.isInt() }
}
}
field("Item price for others") {
textfield(otherPrice){
filterInput { it.controlNewText.isInt() }
}
}
field("Item quantity") {
textfield(itemQuantity){
filterInput { it.controlNewText.isInt() }
}
}
hbox (30) {
button("Add item"){
shortcut("Enter")
action {
if(itemName.get() != "" && itemPrice.get() != 0 && otherPrice.get() != 0 && itemQuantity.get() != 0) {
ItemController.tryAddItem(itemName.get(),itemPrice.get(),otherPrice.get(),itemQuantity.get())
find<ImportOk>().openModal(StageStyle.DECORATED,block = true)
replaceWith(ButtonMenu::class,ViewTransition.Wipe(0.5.seconds, ViewTransition.Direction.LEFT))
}
}
}
button("Back"){
action {
replaceWith(ButtonMenu::class,ViewTransition.Wipe(0.5.seconds, ViewTransition.Direction.LEFT))
}
}
}
}
}
override fun onUndock(){
itemName.set("")
itemPrice.set(0)
otherPrice.set(0)
itemQuantity.set(0)
}
}
Sorry for offtop but It's not a good practice to push all your code here. If you have isolated a bug, please create as compact example as possible in order to quickly understand what's going on here.
How did you package it ? Is it about Java 8 / TornadoFX 1.7+ ? Maybe it's an environment problem.