Sub AddKeyPressedListener
Dim r As Reflector
r.Target = MainForm.RootPane
r.AddEventFilter("keypressed", "javafx.scene.input.KeyEvent.ANY")
End Sub
Sub KeyPressed_Filter (e As Event)
If Dialog.Visible Then
Dim jo As JavaObject = e
Dim EventType As String = jo.RunMethodJO("getEventType", Null).RunMethod("getName", Null)
If EventType = "KEY_RELEASED" Then
Dim keycode As String = jo.RunMethod("getCode", Null)
If keycode = "ESCAPE" Then
Dialog.Close(xui.DialogResponse_Cancel)
Else If keycode = "Y" Then
Dialog.Close(xui.DialogResponse_Positive)
Else If keycode = "N" Then
Dialog.Close(xui.DialogResponse_Negative)
End If
End If
e.Consume
End If
End Sub