mirror of
https://github.com/Ttanasart-pt/Pixel-Composer.git
synced 2024-12-24 14:06:23 +01:00
- [Text Inputs] Fix some modifier keys (eg. backspace, tab, etc.) not trigger.
This commit is contained in:
parent
4668cde2fd
commit
f2067f1eaf
14 changed files with 284 additions and 42 deletions
|
@ -893,6 +893,7 @@
|
|||
{"name":"s_node_print","order":30,"path":"sprites/s_node_print/s_node_print.yy",},
|
||||
{"name":"sh_seperate_shape_counter","order":1,"path":"shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.yy",},
|
||||
{"name":"s_node_stack","order":37,"path":"sprites/s_node_stack/s_node_stack.yy",},
|
||||
{"name":"hlsl_server","order":2,"path":"scripts/hlsl_server/hlsl_server.yy",},
|
||||
{"name":"s_fade_up","order":3,"path":"sprites/s_fade_up/s_fade_up.yy",},
|
||||
{"name":"panel_globalvar","order":2,"path":"scripts/panel_globalvar/panel_globalvar.yy",},
|
||||
{"name":"__node_3d_render","order":5,"path":"scripts/__node_3d_render/__node_3d_render.yy",},
|
||||
|
|
|
@ -1523,6 +1523,7 @@
|
|||
{"id":{"name":"s_node_print","path":"sprites/s_node_print/s_node_print.yy",},},
|
||||
{"id":{"name":"sh_seperate_shape_counter","path":"shaders/sh_seperate_shape_counter/sh_seperate_shape_counter.yy",},},
|
||||
{"id":{"name":"s_node_stack","path":"sprites/s_node_stack/s_node_stack.yy",},},
|
||||
{"id":{"name":"hlsl_server","path":"scripts/hlsl_server/hlsl_server.yy",},},
|
||||
{"id":{"name":"s_fade_up","path":"sprites/s_fade_up/s_fade_up.yy",},},
|
||||
{"id":{"name":"panel_globalvar","path":"scripts/panel_globalvar/panel_globalvar.yy",},},
|
||||
{"id":{"name":"__node_3d_render","path":"scripts/__node_3d_render/__node_3d_render.yy",},},
|
||||
|
|
Binary file not shown.
|
@ -31,6 +31,8 @@
|
|||
//}
|
||||
|
||||
if(selecting == i) {
|
||||
WIDGET_TAB_BLOCK = true;
|
||||
|
||||
draw_sprite_stretched_ext(THEME.textbox, 3, 0, _ly, _dw, hght, COLORS.dialog_menubox_highlight, 1);
|
||||
|
||||
if(keyboard_check_pressed(vk_tab))
|
||||
|
@ -69,8 +71,9 @@
|
|||
|
||||
function applyAutoComplete(rep) {
|
||||
var line = array_safe_get(textbox._input_text_line, textbox.cursor_line, "");
|
||||
var crop = string_copy(line, 1, textbox.cursor - textbox.char_run);
|
||||
var rest = string_copy(line, textbox.cursor + 1, string_length(line) - textbox.cursor);
|
||||
var _line_curs = textbox.cursor - textbox.char_run;
|
||||
var crop = string_copy(line, 1, _line_curs);
|
||||
var rest = string_copy(line, _line_curs + 1, string_length(line) - _line_curs);
|
||||
var slp = string_splice(crop, [" ", "(", ","], true);
|
||||
slp[array_length(slp) - 1] = rep;
|
||||
|
||||
|
@ -92,7 +95,6 @@
|
|||
textbox.cursor += shf;
|
||||
textbox._input_text = txt;
|
||||
textbox.cut_line();
|
||||
textbox.apply();
|
||||
|
||||
active = false;
|
||||
}
|
||||
|
|
|
@ -6,9 +6,13 @@ kb_hold = false;
|
|||
KEYBOARD_PRESSED = kb_hkey;
|
||||
|
||||
if(keyboard_check(vk_backspace))
|
||||
KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1);
|
||||
KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1);
|
||||
else
|
||||
KEYBOARD_STRING += keyboard_lastchar;
|
||||
|
||||
//if(WIDGET_CURRENT && is_instanceof(WIDGET_CURRENT, textInput))
|
||||
// WIDGET_CURRENT.onKey(KEYBOARD_PRESSED);
|
||||
if(KEYBOARD_PRESSED == -1) {
|
||||
for( var i = 0, n = array_length(global.KEYS_VK); i < n; i++ ) {
|
||||
if(keyboard_check(global.KEYS_VK[i]))
|
||||
KEYBOARD_PRESSED = global.KEYS_VK[i];
|
||||
}
|
||||
}
|
|
@ -91,6 +91,18 @@ function array_exists(arr, val) {
|
|||
});
|
||||
}
|
||||
|
||||
function array_overlap(arr0, arr1) {
|
||||
gml_pragma("forceinline");
|
||||
self.__temp_arr = arr1;
|
||||
|
||||
if(!is_array(arr0)) return false;
|
||||
if(!is_array(arr1)) return false;
|
||||
|
||||
return array_any(arr0, function(_val, _ind) {
|
||||
return array_exists(self.__temp_arr, _val);
|
||||
});
|
||||
}
|
||||
|
||||
function array_empty(arr) {
|
||||
gml_pragma("forceinline");
|
||||
return is_array(arr) && array_length(arr) == 0;
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
#region key list
|
||||
global.KEYS_VK = [
|
||||
vk_left, vk_right, vk_up, vk_down, vk_space, vk_backspace, vk_tab, vk_home, vk_end, vk_delete, vk_insert,
|
||||
vk_pageup, vk_pagedown, vk_pause, vk_printscreen,
|
||||
vk_f1, vk_f2, vk_f3, vk_f4, vk_f5, vk_f6, vk_f7, vk_f8, vk_f9, vk_f10, vk_f11, vk_f12,
|
||||
];
|
||||
#endregion
|
||||
|
||||
#region keyboard
|
||||
enum KEYBOARD_STATUS {
|
||||
idle,
|
||||
|
|
|
@ -23,7 +23,9 @@ function draw_text_bbox(bbox, text) {
|
|||
}
|
||||
|
||||
function draw_text_cut(x, y, str, w, scale = 1) {
|
||||
BLEND_ALPHA_MULP;
|
||||
draw_text_transformed(x, y, string_cut(str, w,, scale), scale, scale, 0);
|
||||
BLEND_NORMAL;
|
||||
}
|
||||
|
||||
function __draw_text_ext_transformed(_x, _y, _text, _sep, _w, sx, sy, rotation) {
|
||||
|
|
182
scripts/hlsl_server/hlsl_server.gml
Normal file
182
scripts/hlsl_server/hlsl_server.gml
Normal file
|
@ -0,0 +1,182 @@
|
|||
#region functions
|
||||
global.HLSL_FUNCTIONS = ds_map_create();
|
||||
global.HLSL_FUNCTIONS[? "abs"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "acos"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "asfloat"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "asin"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "asint"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "atan"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "atan2"] = ["y", "x"];
|
||||
global.HLSL_FUNCTIONS[? "ceil"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "clamp"] = ["x", "min", "max"];
|
||||
global.HLSL_FUNCTIONS[? "clip"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "cos"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "cosh"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "cross"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "ddx"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "ddy"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "degrees"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "determinant"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "distance"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "dot"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "exp"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "exp2"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "faceforward"] = ["n", "i", "ng"];
|
||||
global.HLSL_FUNCTIONS[? "floor"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "fma"] = ["a", "b", "c"];
|
||||
global.HLSL_FUNCTIONS[? "fmod"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "frac"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "frexp"] = ["x", "exp"];
|
||||
global.HLSL_FUNCTIONS[? "fwidth"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "isfinite"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "isinf"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "isnan"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "ldexp"] = ["x", "exp"];
|
||||
global.HLSL_FUNCTIONS[? "length"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "lerp"] = ["x", "y", "s"];
|
||||
global.HLSL_FUNCTIONS[? "lit"] = ["n_dot_l", "n_dot_h", "m"];
|
||||
global.HLSL_FUNCTIONS[? "log"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "log10"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "log2"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "max"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "min"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "modf"] = ["x", "out ip"];
|
||||
global.HLSL_FUNCTIONS[? "mul"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "noise"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "normalize"]= ["x"];
|
||||
global.HLSL_FUNCTIONS[? "pow"] = ["x", "y"];
|
||||
global.HLSL_FUNCTIONS[? "radians"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "rcp"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "reflect"] = ["i", "n"];
|
||||
global.HLSL_FUNCTIONS[? "refract"] = ["i", "n", "?"];
|
||||
global.HLSL_FUNCTIONS[? "round"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "rsqrt"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "saturate"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "sign"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "sin"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "sincos"] = ["x", "out s", "out c"];
|
||||
global.HLSL_FUNCTIONS[? "sinh"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "smoothstep"] = ["min", "max", "x"];
|
||||
global.HLSL_FUNCTIONS[? "sqrt"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "step"] = ["y", "x"];
|
||||
global.HLSL_FUNCTIONS[? "tan"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "tanh"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "transpose"] = ["x"];
|
||||
global.HLSL_FUNCTIONS[? "trunc"] = ["x"];
|
||||
#endregion
|
||||
|
||||
global.HLSL_VAR = [ "float", "int", "float2", "float3", "float4", "float3x3", "float4x4", "sampler" ];
|
||||
|
||||
function hlsl_document_parser(prompt, node = noone) {
|
||||
var params = [];
|
||||
var lines = string_split(prompt, "\n");
|
||||
|
||||
for( var i = node.input_fix_len, n = ds_list_size(node.inputs); i < n; i += node.data_length ) {
|
||||
var _arg_name = node.inputs[| i + 0].getValue();
|
||||
var _arg_type = node.inputs[| i + 1].getValue();
|
||||
|
||||
params = array_push(params, [ _arg_name, array_safe_get(global.HLSL_VAR, _arg_type) ]);
|
||||
}
|
||||
|
||||
for( var i = 0, n = array_length(lines); i < n; i++ ) {
|
||||
var line = string_trim(lines[i]);
|
||||
var _token = string_split(line, " ");
|
||||
var _vari = false;
|
||||
var _vart = "";
|
||||
var _vars = "";
|
||||
|
||||
for( var j = 0, m = array_length(_token); j < m; j++ ) {
|
||||
if(_vari)
|
||||
_vars += _token[j];
|
||||
|
||||
if(array_exists(global.HLSL_VAR, _token[j])) {
|
||||
_vart = _token[j];
|
||||
_vari = true;
|
||||
}
|
||||
}
|
||||
|
||||
_vars = string_replace_all(_vars, ";", "");
|
||||
_vars = string_replace_all(_vars, " ", "");
|
||||
_vars = string_splice(_vars, ",");
|
||||
|
||||
var _varType = [];
|
||||
|
||||
for( var j = 0, m = array_length(_vars); j < m; j++ ) {
|
||||
var _eq = string_splice(_vars[j], "=");
|
||||
_varType[j] = [ _eq[0], _vart ];
|
||||
}
|
||||
|
||||
params = array_append(params, _varType);
|
||||
}
|
||||
|
||||
return params;
|
||||
}
|
||||
|
||||
function hlsl_autocomplete_server(prompt, params = []) {
|
||||
var res = [];
|
||||
var pr_list = ds_priority_create();
|
||||
|
||||
//////////////////////////////////
|
||||
ds_priority_clear(pr_list);
|
||||
|
||||
for( var i = 0, n = array_length(params); i < n; i++ ) {
|
||||
var gl = params[i];
|
||||
|
||||
var match = string_partial_match(string_lower(gl[0]), string_lower(prompt));
|
||||
if(match == -9999) continue;
|
||||
|
||||
ds_priority_add(pr_list, [[THEME.ac_constant, 2], gl[0], gl[1], gl[0]], match);
|
||||
}
|
||||
|
||||
repeat(ds_priority_size(pr_list))
|
||||
array_push(res, ds_priority_delete_max(pr_list));
|
||||
|
||||
//////////////////////////////////
|
||||
ds_priority_clear(pr_list);
|
||||
|
||||
for( var i = 0, n = array_length(global.HLSL_VAR); i < n; i++ ) {
|
||||
var gl = global.HLSL_VAR[i];
|
||||
|
||||
var match = string_partial_match(string_lower(gl), string_lower(prompt));
|
||||
if(match == -9999) continue;
|
||||
|
||||
ds_priority_add(pr_list, [[THEME.ac_constant, 3], gl, "var type", gl], match);
|
||||
}
|
||||
|
||||
repeat(ds_priority_size(pr_list))
|
||||
array_push(res, ds_priority_delete_max(pr_list));
|
||||
|
||||
//////////////////////////////////
|
||||
ds_priority_clear(pr_list);
|
||||
|
||||
var F = global.HLSL_FUNCTIONS;
|
||||
var _keys = ds_map_keys_to_array(F);
|
||||
|
||||
for( var i = 0, n = array_length(_keys); i < n; i++ ) {
|
||||
var _key = _keys[i];
|
||||
var match = string_partial_match(string_lower(_key), string_lower(prompt));
|
||||
if(match == -9999)
|
||||
continue;
|
||||
|
||||
ds_priority_add(pr_list, [[THEME.ac_function, 0], _key, "function", _key], match);
|
||||
}
|
||||
|
||||
repeat(ds_priority_size(pr_list))
|
||||
array_push(res, ds_priority_delete_max(pr_list));
|
||||
|
||||
ds_priority_destroy(pr_list);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
function hlsl_function_guide_server(prompt) {
|
||||
if(!ds_map_exists(global.HLSL_FUNCTIONS, prompt)) return "";
|
||||
|
||||
var fn = global.HLSL_FUNCTIONS[? prompt];
|
||||
var guide = prompt + "(";
|
||||
for( var i = 0, n = array_length(fn); i < n; i++ )
|
||||
guide += (i? ", " : "") + string(fn[i]);
|
||||
guide += ")";
|
||||
|
||||
return guide;
|
||||
}
|
11
scripts/hlsl_server/hlsl_server.yy
Normal file
11
scripts/hlsl_server/hlsl_server.yy
Normal file
|
@ -0,0 +1,11 @@
|
|||
{
|
||||
"resourceType": "GMScript",
|
||||
"resourceVersion": "1.0",
|
||||
"name": "hlsl_server",
|
||||
"isCompatibility": false,
|
||||
"isDnD": false,
|
||||
"parent": {
|
||||
"name": "GLSL",
|
||||
"path": "folders/functions/GLSL.yy",
|
||||
},
|
||||
}
|
|
@ -981,6 +981,11 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
|
|||
return setValueDirect(str);
|
||||
});
|
||||
|
||||
editWidget.autocomplete_server = hlsl_autocomplete_server;
|
||||
editWidget.function_guide_server = hlsl_function_guide_server;
|
||||
editWidget.parser_server = hlsl_document_parser;
|
||||
editWidget.autocomplete_object = node;
|
||||
|
||||
editWidget.font = f_code;
|
||||
editWidget.format = TEXT_AREA_FORMAT.codeHLSL;
|
||||
editWidget.min_lines = 4;
|
||||
|
|
|
@ -9,6 +9,11 @@ function Panel_Text_Editor(_textArea, _inputFunc, _context) : PanelContent() con
|
|||
self._textArea.font = _textArea.font;
|
||||
self._textArea.format = _textArea.format;
|
||||
|
||||
self._textArea.parser_server = _textArea.parser_server;
|
||||
self._textArea.autocomplete_server = _textArea.autocomplete_server;
|
||||
self._textArea.autocomplete_object = _textArea.autocomplete_object;
|
||||
self._textArea.function_guide_server = _textArea.function_guide_server;
|
||||
|
||||
self.inputFunc = method(self, _inputFunc);
|
||||
self.context = _context;
|
||||
|
||||
|
|
|
@ -49,6 +49,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
autocomplete_box = instance_create(0, 0, o_dialog_textbox_autocomplete);
|
||||
autocomplete_box.textbox = self;
|
||||
autocomplete_server = noone;
|
||||
autocomplete_object = noone;
|
||||
|
||||
function_guide_box = instance_create(0, 0, o_dialog_textbox_function_guide);
|
||||
function_guide_box.textbox = self;
|
||||
|
@ -90,7 +91,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
|
||||
var params = [];
|
||||
if(parser_server != noone)
|
||||
params = parser_server(crop);
|
||||
params = parser_server(crop, autocomplete_object);
|
||||
|
||||
var data = autocomplete_server(pmt, params);
|
||||
|
||||
|
@ -338,10 +339,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
} #endregion
|
||||
|
||||
static editText = function() { #region
|
||||
//print("==========");
|
||||
//print(_input_text);
|
||||
//print($"cursor: {cursor}");
|
||||
|
||||
var _input_text_pre = _input_text;
|
||||
var modified = false;
|
||||
|
||||
#region text editor
|
||||
|
@ -357,7 +355,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
} else {
|
||||
if(key_mod_press(CTRL) && keyboard_check_pressed(ord("V")))
|
||||
KEYBOARD_STRING = clipboard_get_text();
|
||||
|
||||
|
||||
if(keyboard_check_pressed(vk_escape)) {
|
||||
} else if(keyboard_check_pressed(vk_tab)) {
|
||||
} else if(( shift_new_line && keyboard_check_pressed(vk_enter) && key_mod_press(SHIFT)) ||
|
||||
|
@ -432,6 +430,8 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
var str_after = string_copy(_input_text, cursor + 1, string_length(_input_text) - cursor);
|
||||
|
||||
_input_text = str_before + ch + str_after;
|
||||
//print($"{str_before} + {ch} + {str_after}");
|
||||
|
||||
cut_line();
|
||||
move_cursor(string_length(ch));
|
||||
} else {
|
||||
|
@ -451,6 +451,14 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
}
|
||||
}
|
||||
|
||||
//if(modified) {
|
||||
// print("==========");
|
||||
// print(_input_text_pre);
|
||||
// print($"cursor: {cursor}");
|
||||
// print($"press: {KEYBOARD_STRING}");
|
||||
// print(_input_text);
|
||||
//}
|
||||
|
||||
KEYBOARD_STRING = "";
|
||||
keyboard_lastkey = -1;
|
||||
#endregion
|
||||
|
@ -464,8 +472,7 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
if(keyboard_check_pressed(vk_right)) onKey(vk_right);
|
||||
if(keyboard_check_pressed(vk_up)) onKey(vk_up);
|
||||
if(keyboard_check_pressed(vk_down)) onKey(vk_down);
|
||||
|
||||
|
||||
|
||||
if(keyboard_check_pressed(vk_home)) {
|
||||
if(key_mod_press(SHIFT)) {
|
||||
if(cursor_select == -1)
|
||||
|
@ -594,11 +601,13 @@ function textArea(_input, _onModify, _extras = noone) : textInput(_input, _onMod
|
|||
|
||||
if(target != -999) {
|
||||
if(mouse_press(mb_left, active) || click_block == 1) {
|
||||
cursor_select = target;
|
||||
cursor = target;
|
||||
click_block = 0;
|
||||
} else if(mouse_click(mb_left, active) && cursor != target)
|
||||
cursor = target;
|
||||
click_block = 0;
|
||||
} else if(mouse_click(mb_left, active) && cursor != target) {
|
||||
if(cursor_select == -1)
|
||||
cursor_select = cursor;
|
||||
cursor = target;
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
||||
|
|
|
@ -43,22 +43,22 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
|
||||
text_surface = surface_create(1, 1);
|
||||
|
||||
static setSlidable = function(slidable = true) {
|
||||
static setSlidable = function(slidable = true) { #region
|
||||
self.slidable = slidable;
|
||||
return self;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static setFont = function(font) {
|
||||
static setFont = function(font) { #region
|
||||
self.font = font;
|
||||
return self;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static setEmpty = function() {
|
||||
static setEmpty = function() { #region
|
||||
no_empty = false;
|
||||
return self;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static activate = function() {
|
||||
static activate = function() { #region
|
||||
WIDGET_CURRENT = self;
|
||||
WIDGET_CURRENT_SCROLL = parent;
|
||||
parentFocus();
|
||||
|
@ -72,15 +72,15 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
click_block = 1;
|
||||
KEYBOARD_STRING = "";
|
||||
keyboard_lastkey = -1;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static deactivate = function() {
|
||||
static deactivate = function() { #region
|
||||
apply();
|
||||
WIDGET_CURRENT = noone;
|
||||
UNDO_HOLDING = false;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static onKey = function(key) {
|
||||
static onKey = function(key) { #region
|
||||
if(KEYBOARD_PRESSED == vk_left) {
|
||||
if(key_mod_press(SHIFT)) {
|
||||
if(cursor_select == -1)
|
||||
|
@ -100,9 +100,9 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
else
|
||||
move_cursor(1);
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static apply = function() {
|
||||
static apply = function() { #region
|
||||
var _input_text_current = _input_text;
|
||||
disp_x_to = 0;
|
||||
|
||||
|
@ -119,14 +119,14 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
if(is_callable(onModify))
|
||||
return onModify(_input_text_current);
|
||||
return false;
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static move_cursor = function(delta) {
|
||||
static move_cursor = function(delta) { #region
|
||||
var ll = string_length(_input_text) + 1;
|
||||
cursor = safe_mod(cursor + delta + ll, ll);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static editText = function() {
|
||||
static editText = function() { #region
|
||||
#region text editor
|
||||
if(key_mod_press(CTRL) && keyboard_check_pressed(ord("A"))) {
|
||||
cursor_select = 0;
|
||||
|
@ -230,9 +230,9 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
deactivate();
|
||||
else if(auto_update && keyboard_check_pressed(vk_anykey))
|
||||
apply();
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static display_text = function(_x, _y, _text, _w, _m = -1) {
|
||||
static display_text = function(_x, _y, _text, _w, _m = -1) { #region
|
||||
_text = string_real(_text);
|
||||
BLEND_OVERRIDE;
|
||||
if(!interactable) draw_set_alpha(0.5);
|
||||
|
@ -278,13 +278,13 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
} else if(mouse_click(mb_left, active) && cursor != target)
|
||||
cursor = target;
|
||||
}
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static drawParam = function(params) {
|
||||
static drawParam = function(params) { #region
|
||||
return draw(params.x, params.y, params.w, params.h, params.data, params.m, params.halign, params.valign);
|
||||
}
|
||||
} #endregion
|
||||
|
||||
static draw = function(_x, _y, _w, _h, _text = "", _m = mouse_ui, halign = fa_left, valign = fa_top) {
|
||||
static draw = function(_x, _y, _w, _h, _text = "", _m = mouse_ui, halign = fa_left, valign = fa_top) { #region
|
||||
x = _x;
|
||||
y = _y;
|
||||
w = _w;
|
||||
|
@ -537,5 +537,5 @@ function textBox(_input, _onModify, _extras = noone) : textInput(_input, _onModi
|
|||
resetFocus();
|
||||
sprite_index = -1;
|
||||
return _h;
|
||||
}
|
||||
} #endregion
|
||||
}
|
Loading…
Reference in a new issue