Merge pull request #75699 from m4gr3d/fix_ux_controls_3x
[3.x] Fix UI responsiveness to touch taps
This commit is contained in:
commit
dc97a2e543
|
@ -796,18 +796,16 @@ public:
|
||||||
return String();
|
return String();
|
||||||
}
|
}
|
||||||
|
|
||||||
void _gui_input(const Ref<InputEvent> &p_ev) {
|
void _update_hovered(const Vector2 &p_position) {
|
||||||
const Ref<InputEventMouseMotion> mm = p_ev;
|
|
||||||
if (mm.is_valid()) {
|
|
||||||
bool expand_was_hovered = expand_hovered;
|
bool expand_was_hovered = expand_hovered;
|
||||||
expand_hovered = expand_rect.has_point(mm->get_position());
|
expand_hovered = expand_rect.has_point(p_position);
|
||||||
if (expand_hovered != expand_was_hovered) {
|
if (expand_hovered != expand_was_hovered) {
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!expand_hovered) {
|
if (!expand_hovered) {
|
||||||
for (int i = 0; i < flag_rects.size(); i++) {
|
for (int i = 0; i < flag_rects.size(); i++) {
|
||||||
if (flag_rects[i].has_point(mm->get_position())) {
|
if (flag_rects[i].has_point(p_position)) {
|
||||||
// Used to highlight the hovered flag in the layers grid.
|
// Used to highlight the hovered flag in the layers grid.
|
||||||
hovered_index = i;
|
hovered_index = i;
|
||||||
update();
|
update();
|
||||||
|
@ -821,12 +819,20 @@ public:
|
||||||
hovered_index = -1;
|
hovered_index = -1;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Ref<InputEventMouseButton> mb = p_ev;
|
void _on_hover_exit() {
|
||||||
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
|
if (expand_hovered) {
|
||||||
|
expand_hovered = false;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
if (hovered_index != -1) {
|
||||||
|
hovered_index = -1;
|
||||||
|
update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _update_flag() {
|
||||||
if (hovered_index >= 0) {
|
if (hovered_index >= 0) {
|
||||||
// Toggle the flag.
|
// Toggle the flag.
|
||||||
// We base our choice on the hovered flag, so that it always matches the hovered flag.
|
// We base our choice on the hovered flag, so that it always matches the hovered flag.
|
||||||
|
@ -844,6 +850,19 @@ public:
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void _gui_input(const Ref<InputEvent> &p_ev) {
|
||||||
|
const Ref<InputEventMouseMotion> mm = p_ev;
|
||||||
|
if (mm.is_valid()) {
|
||||||
|
_update_hovered(mm->get_position());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const Ref<InputEventMouseButton> mb = p_ev;
|
||||||
|
if (mb.is_valid() && mb->get_button_index() == BUTTON_LEFT && mb->is_pressed()) {
|
||||||
|
_update_hovered(mb->get_position());
|
||||||
|
_update_flag();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void _notification(int p_what) {
|
void _notification(int p_what) {
|
||||||
|
@ -974,14 +993,7 @@ public:
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case NOTIFICATION_MOUSE_EXIT: {
|
case NOTIFICATION_MOUSE_EXIT: {
|
||||||
if (expand_hovered) {
|
_on_hover_exit();
|
||||||
expand_hovered = false;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
if (hovered_index != -1) {
|
|
||||||
hovered_index = -1;
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
|
@ -193,12 +193,14 @@ void Tabs::_gui_input(const Ref<InputEvent> &p_event) {
|
||||||
for (int i = offset; i <= max_drawn_tab; i++) {
|
for (int i = offset; i <= max_drawn_tab; i++) {
|
||||||
if (tabs[i].rb_rect.has_point(pos)) {
|
if (tabs[i].rb_rect.has_point(pos)) {
|
||||||
rb_pressing = true;
|
rb_pressing = true;
|
||||||
|
_update_hover();
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tabs[i].cb_rect.has_point(pos) && (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current))) {
|
if (tabs[i].cb_rect.has_point(pos) && (cb_displaypolicy == CLOSE_BUTTON_SHOW_ALWAYS || (cb_displaypolicy == CLOSE_BUTTON_SHOW_ACTIVE_ONLY && i == current))) {
|
||||||
cb_pressing = true;
|
cb_pressing = true;
|
||||||
|
_update_hover();
|
||||||
update();
|
update();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue