diff --git a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java index edf1de646f..da84ea4ba1 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java +++ b/bundles/org.eclipse.swt/Eclipse SWT Browser/win32/org/eclipse/swt/browser/Edge.java @@ -1573,9 +1573,12 @@ int handleAcceleratorKeyPressed(long pView, long pArgs) { return COM.S_OK; } - if (!sendKeyEvent(keyEvent)) { - args.put_Handled(true); - } + asyncExec(() -> { + sendKeyEvent(keyEvent); + }); + + boolean hasListener = browser.getListeners(keyEvent.type).length != 0 || browser.getDisplay().filters(keyEvent.type); + args.put_Handled(hasListener); } else { keyEvent.type = SWT.KeyUp; browser.notifyListeners (keyEvent.type, keyEvent); diff --git a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java index dc2caec029..82a230fa74 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/cocoa/org/eclipse/swt/widgets/Display.java @@ -1224,7 +1224,33 @@ boolean filterEvent (Event event) { return false; } -boolean filters (int eventType) { +/** + * Checks for if there exists a listener in the collection of listeners who will + * be notified when an event of the given type occurs anywhere in a widget. The event type is one of the event constants + * defined in class SWT. When the event does occur, + * the listener is notified by sending it the handleEvent() + * message. + * + *

+ * Filters are listeners which are registered at display level by calling {@link Display#addFilter(int, Listener)}. These listeners are triggered when there happens an event of the type they are registered with, anywhere in an SWT application. + *

+ * + *

+ * Needs to be public as the consumers of display can register a filter from any package using public method addFilter and might need to check if there exists a filter for an event. + *

+ * + * @param eventType the type of an event to check if there exists a listener registered using addFilter + * @return true if there exists a listener which reacts to the eventType otherwise false + * + * @see Listener + * @see SWT + * @see #addFilter + * @see #removeFilter + * @see #removeListener + * + * @since 3.133 + */ +public boolean filters (int eventType) { if (filterTable == null) return false; return filterTable.hooks (eventType); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java index 132f293b13..5d5180b7ab 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Display.java @@ -1987,7 +1987,33 @@ boolean filterEvent (Event event) { return false; } -boolean filters (int eventType) { +/** + * Checks for if there exists a listener in the collection of listeners who will + * be notified when an event of the given type occurs anywhere in a widget. The event type is one of the event constants + * defined in class SWT. When the event does occur, + * the listener is notified by sending it the handleEvent() + * message. + * + *

+ * Filters are listeners which are registered at display level by calling {@link Display#addFilter(int, Listener)}. These listeners are triggered when there happens an event of the type they are registered with, anywhere in an SWT application. + *

+ * + *

+ * Needs to be public as the consumers of display can register a filter from any package using public method addFilter and might need to check if there exists a filter for an event. + *

+ * + * @param eventType the type of an event to check if there exists a listener registered using addFilter + * @return true if there exists a listener which reacts to the eventType otherwise false + * + * @see Listener + * @see SWT + * @see #addFilter + * @see #removeFilter + * @see #removeListener + * + * @since 3.133 + */ +public boolean filters (int eventType) { if (filterTable == null) return false; return filterTable.hooks (eventType); } diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java index 84b1c94fd7..0b707e9c8a 100644 --- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java +++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Display.java @@ -1347,7 +1347,35 @@ boolean filterEvent (Event event) { return false; } -boolean filters (int eventType) { + + +/** + * Checks for if there exists a listener in the collection of listeners who will + * be notified when an event of the given type occurs anywhere in a widget. The event type is one of the event constants + * defined in class SWT. When the event does occur, + * the listener is notified by sending it the handleEvent() + * message. + * + *

+ * Filters are listeners which are registered at display level by calling {@link Display#addFilter(int, Listener)}. These listeners are triggered when there happens an event of the type they are registered with, anywhere in an SWT application. + *

+ * + *

+ * Needs to be public as the consumers of display can register a filter from any package using public method addFilter and might need to check if there exists a filter for an event. + *

+ * + * @param eventType the type of an event to check if there exists a listener registered using addFilter + * @return true if there exists a listener which reacts to the eventType otherwise false + * + * @see Listener + * @see SWT + * @see #addFilter + * @see #removeFilter + * @see #removeListener + * + * @since 3.133 + */ +public boolean filters (int eventType) { if (filterTable == null) return false; return filterTable.hooks (eventType); }