I have a JavaFX scene containing a Label, ListView and a Button. My action event is not firing when the button is clicked. Does anyone know why this might be happening? The application so far has two scenes. The first scene is changing to this scene by setting the Stage’s scene member to an instance of this scene.
public class CharacterSelectScene extends Scene, CharacterSelectUi {
var listener: CharacterSelectUiListener;
var characters: Sequence;
var listView: ListView;
override public function setCharacterSelectUiListener(arg0: CharacterSelectUiListener): Void {
this.listener = listener;
}
override public function setCharacters(arg0: Map): Void {
characters = for (k in arg0.keySet()) {
CharacterEntry {
id: k as CharacterId
name: arg0.get(k) as String
}
}
}
override public function getCharacterSelectUiListener(): CharacterSelectUiListener {
return listener;
}
override public function setCharacterSelectEnabled(arg0: Boolean): Void {
}
init {
listView = ListView {
translateX: 0
translateY: 0
layoutInfo: LayoutInfo { height: 150 }
items: bind characters;
cellFactory: function() {
def cell: ListCell = ListCell {
node: HBox {
content: [
Label { text: bind
if (cell.empty)
then ""
else ((cell.item as CharacterEntry).name) }
]
}
}
}
};
content = VBox {
content: [
Text { content: "Characters" },
listView,
Button {
text: "Select"
action: function() {
if (listener != null) {
var ch : CharacterEntry = listView.selectedItem as CharacterEntry;
if (ch != null) {
listener.characterSelected(ch.id);
}
}
}
}
]
}
}
}