mirror of
https://github.com/godotengine/godot.git
synced 2025-10-24 18:33:36 +00:00
Merge pull request #20385 from moiman100/unify-double-clicking
Added double clicking to all buttons on Linux and Javascript
This commit is contained in:
commit
5f32fc8208
4 changed files with 49 additions and 6 deletions
|
|
@ -295,6 +295,30 @@ EM_BOOL OS_JavaScript::mouse_button_callback(int p_event_type, const EmscriptenM
|
|||
default: return false;
|
||||
}
|
||||
|
||||
if (ev->is_pressed()) {
|
||||
|
||||
uint64_t diff = p_event->timestamp - os->last_click_ms;
|
||||
|
||||
if (ev->get_button_index() == os->last_click_button_index) {
|
||||
|
||||
if (diff < 400 && Point2(os->last_click_pos).distance_to(ev->get_position()) < 5) {
|
||||
|
||||
os->last_click_ms = 0;
|
||||
os->last_click_pos = Point2(-100, -100);
|
||||
os->last_click_button_index = -1;
|
||||
ev->set_doubleclick(true);
|
||||
}
|
||||
|
||||
} else {
|
||||
os->last_click_button_index = ev->get_button_index();
|
||||
}
|
||||
|
||||
if (!ev->is_doubleclick()) {
|
||||
os->last_click_ms += diff;
|
||||
os->last_click_pos = ev->get_position();
|
||||
}
|
||||
}
|
||||
|
||||
int mask = os->input->get_mouse_button_mask();
|
||||
int button_flag = 1 << (ev->get_button_index() - 1);
|
||||
if (ev->is_pressed()) {
|
||||
|
|
@ -1070,6 +1094,10 @@ OS_JavaScript::OS_JavaScript(int p_argc, char *p_argv[]) {
|
|||
}
|
||||
set_cmdline(p_argv[0], arguments);
|
||||
|
||||
last_click_button_index = -1;
|
||||
last_click_ms = 0;
|
||||
last_click_pos = Point2(-100, -100);
|
||||
|
||||
window_maximized = false;
|
||||
entering_fullscreen = false;
|
||||
just_exited_fullscreen = false;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue