- Fix dialog not closing when trying to click outside on pen tablet.

This commit is contained in:
Tanasart 2024-07-16 14:08:27 +07:00
parent 3c1d49aeb9
commit 906d46ca3d
4 changed files with 23 additions and 24 deletions

View file

@ -196,17 +196,16 @@
}
function checkMouse() {
if(!active) return;
if(!DIALOG_CLICK) return;
if(!active) return;
if(!DIALOG_CLICK) return;
if(!init_pressing && mouse_press(mb_any)) {
if(!isTop()) return;
if(!isTop()) return;
for( var i = 0, n = array_length(children); i < n; i++ )
if(instance_exists(children[i])) return;
if(checkClosable() && destroy_on_click_out)
if(!point_in(mouse_mx, mouse_my)) {
if(checkClosable() && destroy_on_click_out && !point_in(mouse_mx, mouse_my)) {
instance_destroy(self);
onDestroy();
DIALOG_CLICK = false;

View file

@ -13,7 +13,7 @@ event_inherited();
content = noone;
destroy_on_click_out = true;
function setContent(content) { #region
function setContent(content) {
self.content = content;
if(struct_has(content, "title_height"))
@ -29,14 +29,14 @@ event_inherited();
content.in_dialog = true;
if(content.auto_pin) destroy_on_click_out = false;
} #endregion
}
function contentResize() { #region
function contentResize() {
dialog_w = content.w + content.showHeader * padding * 2;
dialog_h = content.h + content.showHeader * (padding * 2 + title_height);
} #endregion
}
function resetMask() { #region
function resetMask() {
if(!content) return;
mask_surface = surface_verify(mask_surface, dialog_w - content.showHeader * padding * 2,
dialog_h - content.showHeader * (padding * 2 + title_height));
@ -48,9 +48,9 @@ event_inherited();
dialog_h - content.showHeader * (padding * 2 + title_height));
gpu_set_blendmode(bm_normal);
surface_reset_target();
} resetMask(); #endregion
} resetMask();
onResize = function() { #region
onResize = function() {
panel = surface_verify(panel, dialog_w, dialog_h);
resetMask();
@ -60,21 +60,21 @@ event_inherited();
content.onResize();
}
} #endregion
}
function checkClosable() { #region
function checkClosable() {
if(!content) return true;
return content.checkClosable();
} #endregion
}
function onDestroy() { #region
function onDestroy() {
if(content == noone) return;
content.onClose();
} #endregion
}
function remove() { #region
function remove() {
instance_destroy();
} #endregion
}
function onFocusBegin() { if(content) content.onFocusBegin(); }
function onFocusEnd() { if(content) content.onFocusEnd(); }

View file

@ -2,9 +2,9 @@
"$GMObject":"",
"%Name":"o_dialog_panel",
"eventList":[
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"v1","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":0,"eventType":0,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":64,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
{"$GMEvent":"","%Name":"","collisionObjectId":null,"eventNum":75,"eventType":8,"isDnD":false,"name":"","resourceType":"GMEvent","resourceVersion":"2.0",},
],
"managed":true,
"name":"o_dialog_panel",

View file

@ -6,7 +6,7 @@
MOUSE_WRAPPING = false;
MOUSE_BLOCK = false;
_MOUSE_BLOCK = false;
PEN_RELEASED = false;
PEN_RELEASED = false;
#macro SCROLL_SPEED PREFERENCES.mouse_wheel_speed
#macro MOUSE_MOVED (window_mouse_get_delta_x() || window_mouse_get_delta_y())
@ -43,7 +43,7 @@ function mouse_release(mouse, focus = true) { #region
if(PEN_RIGHT_RELEASE) return mouse == mb_right;
return mouse_check_button_released(mouse) || (mouse == mb_left && PEN_RELEASED);
return mouse_check_button_released(mouse) || ((mouse == mb_left || mouse == mb_any) && PEN_RELEASED);
} #endregion
function mouse_lclick(focus = true) { #region