Skip to content

Commit acb748e

Browse files
authored
Merge pull request #52973 from selgesel/patch2
[3.x] Release pressed events when the window is blurred on HTML5 platform
2 parents 047108a + c918b4d commit acb748e

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

platform/javascript/os_javascript.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,11 @@ EM_BOOL OS_JavaScript::fullscreen_change_callback(int p_event_type, const Emscri
121121
return false;
122122
}
123123

124+
EM_BOOL OS_JavaScript::blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data) {
125+
get_singleton()->input->release_pressed_events();
126+
return false;
127+
}
128+
124129
void OS_JavaScript::set_video_mode(const VideoMode &p_video_mode, int p_screen) {
125130
video_mode = p_video_mode;
126131
}
@@ -884,6 +889,7 @@ Error OS_JavaScript::initialize(const VideoMode &p_desired, int p_video_driver,
884889
SET_EM_CALLBACK(canvas_id, mousedown, mouse_button_callback)
885890
SET_EM_WINDOW_CALLBACK(mousemove, mousemove_callback)
886891
SET_EM_WINDOW_CALLBACK(mouseup, mouse_button_callback)
892+
SET_EM_WINDOW_CALLBACK(blur, blur_callback)
887893
SET_EM_CALLBACK(canvas_id, wheel, wheel_callback)
888894
SET_EM_CALLBACK(canvas_id, touchstart, touch_press_callback)
889895
SET_EM_CALLBACK(canvas_id, touchmove, touchmove_callback)

platform/javascript/os_javascript.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ class OS_JavaScript : public OS_Unix {
7272

7373
static Point2 compute_position_in_canvas(int x, int y);
7474
static EM_BOOL fullscreen_change_callback(int p_event_type, const EmscriptenFullscreenChangeEvent *p_event, void *p_user_data);
75+
static EM_BOOL blur_callback(int p_event_type, const EmscriptenFocusEvent *p_event, void *p_user_data);
7576

7677
static EM_BOOL keydown_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data);
7778
static EM_BOOL keypress_callback(int p_event_type, const EmscriptenKeyboardEvent *p_event, void *p_user_data);

0 commit comments

Comments
 (0)