From 6b7e882eabcaf3bc05388cc1425816bc40252233 Mon Sep 17 00:00:00 2001 From: Tanasart Date: Thu, 18 Apr 2024 13:01:23 +0700 Subject: [PATCH] textbox pen slide --- #backups/objects/o_main/o_main.yy.backup0 | 12 ++++--- #backups/objects/o_main/o_main.yy.backup1 | 14 +++++---- #backups/scripts/textBox/textBox.gml.backup0 | 33 +++++++++++--------- #backups/scripts/textBox/textBox.gml.backup1 | 33 +++++++++++--------- objects/o_main/Other_20.gml | 6 ++-- objects/o_main/Step_1.gml | 3 ++ scripts/textBox/textBox.gml | 31 +++++++++--------- 7 files changed, 76 insertions(+), 56 deletions(-) diff --git a/#backups/objects/o_main/o_main.yy.backup0 b/#backups/objects/o_main/o_main.yy.backup0 index 176deb9fa..fd56a6eaf 100644 --- a/#backups/objects/o_main/o_main.yy.backup0 +++ b/#backups/objects/o_main/o_main.yy.backup0 @@ -1,4 +1,4 @@ -// 2024-04-18 11:59:25 +// 2024-04-18 13:01:11 #event properties (no comments/etc. here are saved) parent_index = -1; persistent = true; @@ -653,6 +653,9 @@ _HOVERING_ELEMENT = noone; PEN_RIGHT_PRESS = false; PEN_RIGHT_RELEASE = false; + PEN_X_DELTA = 0; + PEN_Y_DELTA = 0; + if(!IS_CMD) tabletstuff_perform_event(id, ev_other, ev_user10); //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); @@ -1042,7 +1045,6 @@ PROJECT.modified = false; var e; e = tabletstuff_get_event_data(); if (!ds_map_exists(e, "pointer_info_pen")) exit; -PEN_USE = true; /* See: @@ -1062,11 +1064,13 @@ var tx = e[? "pointer_info_pen_tilt_x"]; var ty = e[? "pointer_info_pen_tilt_y"]; PEN_X_DELTA = px - PEN_X; -PEN_Y_DELTA = px - PEN_Y; +PEN_Y_DELTA = py - PEN_Y; PEN_X = px; PEN_Y = py; +// print($"{PEN_X} | {PEN_X_DELTA}"); + PEN_PRESSURE = pp; var contact = bool(f & 0x4); @@ -1083,7 +1087,7 @@ if(PEN_RIGHT_CLICK && !b2) PEN_RIGHT_RELEASE = true; PEN_RIGHT_CLICK = b2; //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); - +PEN_USE = true; #event async_image if(!ds_map_exists(IMAGE_FETCH_MAP, async_load[? "id"])) exit; diff --git a/#backups/objects/o_main/o_main.yy.backup1 b/#backups/objects/o_main/o_main.yy.backup1 index d04f2a3b4..74c92e40b 100644 --- a/#backups/objects/o_main/o_main.yy.backup1 +++ b/#backups/objects/o_main/o_main.yy.backup1 @@ -1,4 +1,4 @@ -// 2024-04-18 11:59:03 +// 2024-04-18 12:59:59 #event properties (no comments/etc. here are saved) parent_index = -1; persistent = true; @@ -653,6 +653,9 @@ _HOVERING_ELEMENT = noone; PEN_RIGHT_PRESS = false; PEN_RIGHT_RELEASE = false; + PEN_X_DELTA = 0; + PEN_Y_DELTA = 0; + if(!IS_CMD) tabletstuff_perform_event(id, ev_other, ev_user10); //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); @@ -1042,7 +1045,6 @@ PROJECT.modified = false; var e; e = tabletstuff_get_event_data(); if (!ds_map_exists(e, "pointer_info_pen")) exit; -PEN_USE = true; /* See: @@ -1062,13 +1064,13 @@ var tx = e[? "pointer_info_pen_tilt_x"]; var ty = e[? "pointer_info_pen_tilt_y"]; PEN_X_DELTA = px - PEN_X; -PEN_Y_DELTA = px - PEN_Y; - -//print($"{PEN_X_DELTA}, {PEN_Y_DELTA}"); +PEN_Y_DELTA = py - PEN_Y; PEN_X = px; PEN_Y = py; +// print($"{PEN_X} | {PEN_X_DELTA}"); + PEN_PRESSURE = pp; var contact = bool(f & 0x4); @@ -1085,7 +1087,7 @@ if(PEN_RIGHT_CLICK && !b2) PEN_RIGHT_RELEASE = true; PEN_RIGHT_CLICK = b2; //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); - +PEN_USE = true; #event async_image if(!ds_map_exists(IMAGE_FETCH_MAP, async_load[? "id"])) exit; diff --git a/#backups/scripts/textBox/textBox.gml.backup0 b/#backups/scripts/textBox/textBox.gml.backup0 index 412246f91..d32f23168 100644 --- a/#backups/scripts/textBox/textBox.gml.backup0 +++ b/#backups/scripts/textBox/textBox.gml.backup0 @@ -1,4 +1,4 @@ -// 2024-04-18 12:07:15 +// 2024-04-18 13:00:44 enum TEXTBOX_INPUT { text, number @@ -21,6 +21,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { slidable = false; sliding = false; + slidePen = false; slide_delta = 0; slide_int = false; slide_speed = 1 / 10; @@ -511,33 +512,38 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { var _defval = toNumber(_current_text); slider_def_val = _defval; slider_cur_val = _defval; - - CURSOR_LOCK_X = mouse_mx; - CURSOR_LOCK_Y = mouse_my; + + slidePen = PEN_USE; + + if(!slidePen) { + CURSOR_LOCK_X = mouse_mx; + CURSOR_LOCK_Y = mouse_my; + } sliding = 2; } if(sliding == 2) { - MOUSE_BLOCK = true; - CURSOR_LOCK = true; + if(!slidePen) + CURSOR_LOCK = true; - if(mouse_check_button_pressed(mb_right)) { + if(mouse_press(mb_right)) { _input_text = string_real(slider_def_val); sliding = 0; apply(); deactivate(); - + UNDO_HOLDING = false; } else { + MOUSE_BLOCK = true; var _s = slide_speed; - var _mdx = PEN_USE? PEN_X_DELTA : window_mouse_get_delta_x(); - var _mdy = PEN_USE? PEN_Y_DELTA : window_mouse_get_delta_y(); + var _mdx = slidePen? PEN_X_DELTA : window_mouse_get_delta_x(); + var _mdy = slidePen? PEN_Y_DELTA : window_mouse_get_delta_y(); var _dx = abs(_mdx) > abs(_mdy)? _mdx : -_mdy; - + if(key_mod_press(CTRL) && !slide_snap) _s *= 10; if(key_mod_press(ALT)) _s /= 10; @@ -695,11 +701,8 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { } if(slidable && mouse_press(mb_left, active)) { - sliding = 1; + sliding = 1; slide_delta = 0; - - slide_mx = _m[0]; - slide_my = _m[1]; } } else if(!hide) diff --git a/#backups/scripts/textBox/textBox.gml.backup1 b/#backups/scripts/textBox/textBox.gml.backup1 index 6c9b7f7e1..9c516b0fe 100644 --- a/#backups/scripts/textBox/textBox.gml.backup1 +++ b/#backups/scripts/textBox/textBox.gml.backup1 @@ -1,4 +1,4 @@ -// 2024-04-18 12:00:32 +// 2024-04-18 13:00:36 enum TEXTBOX_INPUT { text, number @@ -21,6 +21,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { slidable = false; sliding = false; + slidePen = false; slide_delta = 0; slide_int = false; slide_speed = 1 / 10; @@ -511,33 +512,38 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { var _defval = toNumber(_current_text); slider_def_val = _defval; slider_cur_val = _defval; - - CURSOR_LOCK_X = mouse_mx; - CURSOR_LOCK_Y = mouse_my; + + slidePen = PEN_USE; + + if(!slidePen) { + CURSOR_LOCK_X = mouse_mx; + CURSOR_LOCK_Y = mouse_my; + } sliding = 2; } if(sliding == 2) { - MOUSE_BLOCK = true; - CURSOR_LOCK = true; + if(!slidePen) + CURSOR_LOCK = true; - if(mouse_check_button_pressed(mb_right)) { + if(mouse_press(mb_right)) { _input_text = string_real(slider_def_val); sliding = 0; apply(); deactivate(); - + UNDO_HOLDING = false; } else { + MOUSE_BLOCK = true; var _s = slide_speed; - var _mdx = PEN_USE? PEN_X_DELTA : window_mouse_get_delta_x(); - var _mdy = PEN_USE? PEN_Y_DELTA : window_mouse_get_delta_y(); + var _mdx = slidePen? PEN_X_DELTA : window_mouse_get_delta_x(); + var _mdy = slidePen? PEN_Y_DELTA : window_mouse_get_delta_y(); var _dx = abs(_mdx) > abs(_mdy)? _mdx : -_mdy; - + if(key_mod_press(CTRL) && !slide_snap) _s *= 10; if(key_mod_press(ALT)) _s /= 10; @@ -695,11 +701,8 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { } if(slidable && mouse_press(mb_left, active)) { - sliding = 1; + sliding = 1; slide_delta = 0; - - slide_mx = _m[0]; - slide_my = _m[1]; } } else if(!hide) diff --git a/objects/o_main/Other_20.gml b/objects/o_main/Other_20.gml index 404a3707f..f0d8eea4d 100644 --- a/objects/o_main/Other_20.gml +++ b/objects/o_main/Other_20.gml @@ -2,7 +2,6 @@ var e; e = tabletstuff_get_event_data(); if (!ds_map_exists(e, "pointer_info_pen")) exit; -PEN_USE = true; /* See: @@ -22,11 +21,13 @@ var tx = e[? "pointer_info_pen_tilt_x"]; var ty = e[? "pointer_info_pen_tilt_y"]; PEN_X_DELTA = px - PEN_X; -PEN_Y_DELTA = px - PEN_Y; +PEN_Y_DELTA = py - PEN_Y; PEN_X = px; PEN_Y = py; +// print($"{PEN_X} | {PEN_X_DELTA}"); + PEN_PRESSURE = pp; var contact = bool(f & 0x4); @@ -43,3 +44,4 @@ if(PEN_RIGHT_CLICK && !b2) PEN_RIGHT_RELEASE = true; PEN_RIGHT_CLICK = b2; //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); +PEN_USE = true; \ No newline at end of file diff --git a/objects/o_main/Step_1.gml b/objects/o_main/Step_1.gml index d69d4a7fc..7f0bdbf2c 100644 --- a/objects/o_main/Step_1.gml +++ b/objects/o_main/Step_1.gml @@ -63,6 +63,9 @@ _HOVERING_ELEMENT = noone; PEN_RIGHT_PRESS = false; PEN_RIGHT_RELEASE = false; + PEN_X_DELTA = 0; + PEN_Y_DELTA = 0; + if(!IS_CMD) tabletstuff_perform_event(id, ev_other, ev_user10); //print($"{PEN_RIGHT_CLICK} | {PEN_RIGHT_PRESS}, {PEN_RIGHT_RELEASE}"); diff --git a/scripts/textBox/textBox.gml b/scripts/textBox/textBox.gml index 1384c06d2..3fe835abd 100644 --- a/scripts/textBox/textBox.gml +++ b/scripts/textBox/textBox.gml @@ -20,6 +20,7 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { slidable = false; sliding = false; + slidePen = false; slide_delta = 0; slide_int = false; slide_speed = 1 / 10; @@ -510,33 +511,38 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { var _defval = toNumber(_current_text); slider_def_val = _defval; slider_cur_val = _defval; - - CURSOR_LOCK_X = mouse_mx; - CURSOR_LOCK_Y = mouse_my; + + slidePen = PEN_USE; + + if(!slidePen) { + CURSOR_LOCK_X = mouse_mx; + CURSOR_LOCK_Y = mouse_my; + } sliding = 2; } if(sliding == 2) { - MOUSE_BLOCK = true; - CURSOR_LOCK = true; + if(!slidePen) + CURSOR_LOCK = true; - if(mouse_check_button_pressed(mb_right)) { + if(mouse_press(mb_right)) { _input_text = string_real(slider_def_val); sliding = 0; apply(); deactivate(); - + UNDO_HOLDING = false; } else { + MOUSE_BLOCK = true; var _s = slide_speed; - var _mdx = PEN_USE? PEN_X_DELTA : window_mouse_get_delta_x(); - var _mdy = PEN_USE? PEN_Y_DELTA : window_mouse_get_delta_y(); + var _mdx = slidePen? PEN_X_DELTA : window_mouse_get_delta_x(); + var _mdy = slidePen? PEN_Y_DELTA : window_mouse_get_delta_y(); var _dx = abs(_mdx) > abs(_mdy)? _mdx : -_mdy; - + if(key_mod_press(CTRL) && !slide_snap) _s *= 10; if(key_mod_press(ALT)) _s /= 10; @@ -694,11 +700,8 @@ function textBox(_input, _onModify) : textInput(_input, _onModify) constructor { } if(slidable && mouse_press(mb_left, active)) { - sliding = 1; + sliding = 1; slide_delta = 0; - - slide_mx = _m[0]; - slide_my = _m[1]; } } else if(!hide)