In my ScalaFX project I want to create a separate help page for the user in which he/she can click a topic which causes instructions to appear next to the clickable topics.
Problem is that when I create the new scene for the help page no matter what I do I can't move the TextFlow
around. It stays in the same place in top of the ListView
. See picture for reference.
helpMenu.onAction = (ae: ActionEvent) => {
val helpStage = new Stage()
helpStage.setTitle("A wild help stage appears!")
val helpScene = new Scene(scene.width.get * 0.6, scene.height.get * 0.8) {
val listView = new ListView(List.tabulate(3) { n => "Option " + (n + 1) })
val text1 = new Text("This is fine\n*zips coffee*\nThis is all fine.")
val textFlow = new TextFlow(text1)
/*
* Nothing below changes where the text appears in the new scene.
*/
textFlow.layoutX <== listView.width.get
textFlow.alignmentInParent_=(Pos.TOP_RIGHT)
textFlow.alignmentInParent_=(Pos.BASELINE_CENTER)
text1.alignmentInParent_=(Pos.BASELINE_CENTER)
listView.prefHeight <== scene.height.get * 0.4
content.addAll(listView, textFlow)
}
helpStage.setScene(helpScene)
helpStage.show()
helpScene.listView.onMouseClicked = (le: MouseEvent) => {
val item = helpScene.listView.selectionModel.apply.getSelectedItem
}
}
What I want to know is how can I orient text next to the list view? The goal is to make the instructions to appear there. My plan was to use
helpScene.listView.onMouseClicked = (le: MouseEvent) => {
val item = helpScene.listView.selectionModel.apply.getSelectedItem
}
to this purpose since we can easily determine what was clicked inside the list.