From 02db57004caf98d66247434c82c97fd730296ae0 Mon Sep 17 00:00:00 2001 From: LeStegii Date: Fri, 24 May 2024 14:53:22 +0200 Subject: [PATCH] fix(framework): Fix logic for reflection sidecar --- .../internal/ReflectionSidecar.java | 21 ++++++++++--------- 1 file changed, 11 insertions(+), 10 deletions(-) diff --git a/framework/src/main/java/org/fulib/fx/controller/internal/ReflectionSidecar.java b/framework/src/main/java/org/fulib/fx/controller/internal/ReflectionSidecar.java index c009a05..04a393e 100644 --- a/framework/src/main/java/org/fulib/fx/controller/internal/ReflectionSidecar.java +++ b/framework/src/main/java/org/fulib/fx/controller/internal/ReflectionSidecar.java @@ -456,16 +456,17 @@ private EventHandler createKeyEventHandler(Method method, Object insta }; } - private boolean keyEventMatchesAnnotation(KeyEvent event, OnKey annotation) { - return (annotation.code() == KeyCode.UNDEFINED || event.getCode() == annotation.code()) && - (annotation.character().isEmpty() || event.getCharacter().equals(annotation.character())) && - (annotation.text().isEmpty() || event.getText().equals(annotation.text())) && - - // key pressed ==> not strict || key required - (event.isShiftDown() && (!annotation.strict() || annotation.shift())) && - (event.isControlDown() && (!annotation.strict() || annotation.control())) && - (event.isAltDown() && (!annotation.strict() || annotation.alt())) && - (event.isMetaDown() && (!annotation.strict() || annotation.meta())); + private boolean keyEventMatchesAnnotation(KeyEvent event, OnKey onKey) { + return (onKey.code() == KeyCode.UNDEFINED || event.getCode() == onKey.code()) && + (onKey.character().isEmpty() || event.getCharacter().equals(onKey.character())) && + (onKey.text().isEmpty() || event.getText().equals(onKey.text())) && + + // key required and key pressed || key not required and (not strict or strict and not pressed) + // If strict is enabled, the key must not be pressed + (onKey.shift() && event.isShiftDown()) || (!onKey.shift() && (!onKey.strict() || !event.isShiftDown())) && + (onKey.control() && event.isControlDown()) || (!onKey.control() && (!onKey.strict() || !event.isControlDown())) && + (onKey.alt() && event.isAltDown()) || (!onKey.alt() && (!onKey.strict() || !event.isAltDown())) && + (onKey.meta() && event.isMetaDown()) || (!onKey.meta() && (!onKey.strict() || !event.isMetaDown())); } @Override