Merge pull request #93500 from anniryynanen/multi-press
Improve button behavior when multiple mouse buttons are used at the same time
This commit is contained in:
commit
ac80ba71e2
2 changed files with 6 additions and 8 deletions
|
@ -144,7 +144,9 @@ void BaseButton::_toggled(bool p_pressed) {
|
|||
}
|
||||
|
||||
void BaseButton::on_action_event(Ref<InputEvent> p_event) {
|
||||
if (p_event->is_pressed()) {
|
||||
Ref<InputEventMouseButton> mouse_button = p_event;
|
||||
|
||||
if (p_event->is_pressed() && (mouse_button.is_null() || status.hovering)) {
|
||||
status.press_attempt = true;
|
||||
status.pressing_inside = true;
|
||||
emit_signal(SNAME("button_down"));
|
||||
|
@ -174,12 +176,6 @@ void BaseButton::on_action_event(Ref<InputEvent> p_event) {
|
|||
}
|
||||
|
||||
if (!p_event->is_pressed()) {
|
||||
Ref<InputEventMouseButton> mouse_button = p_event;
|
||||
if (mouse_button.is_valid()) {
|
||||
if (!has_point(mouse_button->get_position())) {
|
||||
status.hovering = false;
|
||||
}
|
||||
}
|
||||
status.press_attempt = false;
|
||||
status.pressing_inside = false;
|
||||
emit_signal(SNAME("button_up"));
|
||||
|
|
|
@ -1783,7 +1783,9 @@ void Viewport::_gui_input_event(Ref<InputEvent> p_event) {
|
|||
Control *control = Object::cast_to<Control>(ci);
|
||||
if (control) {
|
||||
if (control->get_focus_mode() != Control::FOCUS_NONE) {
|
||||
if (control != gui.key_focus) {
|
||||
// Grabbing unhovered focus can cause issues when mouse is dragged
|
||||
// with another button held down.
|
||||
if (control != gui.key_focus && gui.mouse_over_hierarchy.has(control)) {
|
||||
control->grab_focus();
|
||||
}
|
||||
break;
|
||||
|
|
Loading…
Reference in a new issue