mirror of
https://github.com/NationalSecurityAgency/ghidra.git
synced 2024-11-23 20:59:58 +00:00
Merge remote-tracking branch
'origin/GP-4681-dragonmacher-mouse-button-fix' into patch (Closes #6624)
This commit is contained in:
commit
d9d0a899db
@ -4,9 +4,9 @@
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
@ -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();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user