GP-4681 - Fix for processing mouse bindings for next / previous history

This commit is contained in:
dragonmacher
2024-06-11 10:32:34 -04:00
parent f36a902831
commit ff15ec0ed6
2 changed files with 36 additions and 2 deletions
@@ -70,6 +70,17 @@ public class MouseBindingMouseEventDispatcher {
toolkit.addAWTEventListener(listener, AWTEvent.MOUSE_EVENT_MASK);
}
private boolean isSettingMouseBinding(MouseEvent e) {
Component destination = e.getComponent();
if (destination == null) {
Component focusOwner = focusProvider.getFocusOwner();
destination = focusOwner;
}
// This is the class we use to set mouse bindings
return destination instanceof MouseEntryTextField;
}
private void process(MouseEvent e) {
int id = e.getID();
@@ -77,6 +88,10 @@ public class MouseBindingMouseEventDispatcher {
return;
}
if (isSettingMouseBinding(e)) {
return; // the user is setting the binding; do not process system actions
}
// always let the application finish processing key events that it started
if (actionInProgress(e)) {
return;
@@ -126,6 +141,16 @@ public class MouseBindingMouseEventDispatcher {
new ActionEvent(source, ActionEvent.ACTION_PERFORMED, command, when, modifiers));
}
int eventButton = e.getButton();
int bindingButton = mouseBinding.getButton();
if (eventButton != bindingButton) {
// We may have missed an event or the user pressed multiple mouse buttons in an
// unexpected sequence. Clear the in-progress action here so we do not consume all
// mouse events indefinitely.
inProgressAction = null;
return false;
}
e.consume();
return true;
}
@@ -92,6 +92,15 @@ public class MouseEntryTextField extends HintTextField {
int modifiersEx = e.getModifiersEx();
int button = e.getButton();
int buttonDownMask = InputEvent.getMaskForButton(button);
if (button == MouseEvent.BUTTON1 && buttonDownMask == modifiersEx) {
// Don't allow the user to bind an unmodified left-click, as odd behavior can ensue.
// We can revisit this if a valid use case is found.
e.consume();
return;
}
processMouseBinding(new MouseBinding(button, modifiersEx), true);
e.consume();
}