Skip to content

Commit 6db5678

Browse files
committed
added the new method.
1 parent b05910d commit 6db5678

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

src/main/java/com/ss/editor/ui/util/UIUtils.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -544,6 +544,19 @@ public static boolean isNotHotKey(@Nullable final KeyEvent event) {
544544
return true;
545545
}
546546

547+
/**
548+
* Consume an event if the condition returns true.
549+
*
550+
* @param event the event.
551+
* @param condition the condition.
552+
*/
553+
@FXThread
554+
public static void consumeIf(@NotNull final KeyEvent event, @NotNull final Predicate<KeyEvent> condition) {
555+
if (condition.test(event)) {
556+
event.consume();
557+
}
558+
}
559+
547560
/**
548561
* Consume an event if the event is not hotkey.
549562
*

0 commit comments

Comments
 (0)