Add raw input capture for different input methods (e.g. Microsoft Pinyin).

This commit is contained in:
Tanasart 2025-02-03 14:51:17 +07:00
parent 174cdcf18e
commit 352c88af5d
13 changed files with 121 additions and 38 deletions

Binary file not shown.

View file

@ -243,7 +243,8 @@ event_inherited();
for( var i = 0, n = array_length(_new_node.outputs); i < n; i++ ) for( var i = 0, n = array_length(_new_node.outputs); i < n; i++ )
array_push(_outputs, _new_node.outputs[i]); array_push(_outputs, _new_node.outputs[i]);
PANEL_INSPECTOR.setInspecting(_new_node); if(PANEL_INSPECTOR) PANEL_INSPECTOR.setInspecting(_new_node);
if(PANEL_GRAPH) PANEL_GRAPH.selectDragNode(_new_node, PREFERENCES.node_add_select);
} else if(is_instanceof(_node, NodeAction)) { // NOT IMPLEMENTED } else if(is_instanceof(_node, NodeAction)) { // NOT IMPLEMENTED
var _dat = _node.build(node_target_x, node_target_y,, _param); var _dat = _node.build(node_target_x, node_target_y,, _param);

View file

@ -3,14 +3,16 @@ kb_hkey = vk_nokey;
if(kb_hkey < 0 && keyboard_key > 0) kb_hkey = keyboard_key; if(kb_hkey < 0 && keyboard_key > 0) kb_hkey = keyboard_key;
if(kb_hkey < 0 && keyboard_lastkey > 0) kb_hkey = keyboard_lastkey; if(kb_hkey < 0 && keyboard_lastkey > 0) kb_hkey = keyboard_lastkey;
if(kb_hkey <= 0) for(var i = 2; i < 320; i++) if(keyboard_check_pressed(i)) { kb_hkey = i; break; } if(kb_hkey <= 0 && PREFERENCES.keyboard_check_sweep) for(var i = 2; i < 320; i++) if(keyboard_check_pressed(i)) { kb_hkey = i; break; }
kb_time = 0; kb_time = 0;
kb_hold = false; kb_hold = false;
KEYBOARD_PRESSED = kb_hkey; KEYBOARD_PRESSED = kb_hkey;
if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); if(!PREFERENCES.keyboard_capture_raw) {
else KEYBOARD_STRING += keyboard_lastchar; if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1);
else KEYBOARD_STRING += keyboard_lastchar;
}
if(KEYBOARD_PRESSED == -1) { if(KEYBOARD_PRESSED == -1) {
for( var i = 0, n = array_length(global.KEYS_VK); i < n; i++ ) { for( var i = 0, n = array_length(global.KEYS_VK); i < n; i++ ) {

View file

@ -17,8 +17,10 @@ if(!trigger) exit;
KEYBOARD_PRESSED = kb_hkey; KEYBOARD_PRESSED = kb_hkey;
if(keyboard_check(vk_backspace)) KEYBOARD_STRING = string_copy(KEYBOARD_STRING, 1, string_length(KEYBOARD_STRING) - 1); if(!PREFERENCES.keyboard_capture_raw) {
else KEYBOARD_STRING += keyboard_lastchar; if(keyboard_check(vk_backspace)) 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)) if(WIDGET_CURRENT && is_instanceof(WIDGET_CURRENT, textInput))
WIDGET_CURRENT.onKey(KEYBOARD_PRESSED); WIDGET_CURRENT.onKey(KEYBOARD_PRESSED);

View file

@ -13,6 +13,13 @@ _HOVERING_ELEMENT = noone;
FILE_DROPPED = _FILE_DROPPED; FILE_DROPPED = _FILE_DROPPED;
_FILE_DROPPED = false; _FILE_DROPPED = false;
#region keybord captures
if(PREFERENCES.keyboard_capture_raw && keyboard_string != "") {
KEYBOARD_STRING = keyboard_string;
keyboard_string = "";
}
#endregion
#region minimize #region minimize
if(winMan_isMinimized()) { if(winMan_isMinimized()) {
if(!minimized) game_set_speed(1, gamespeed_fps); if(!minimized) game_set_speed(1, gamespeed_fps);

View file

@ -1334,12 +1334,12 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
} }
for( var i = 0, n = array_length(inputs); i < n; i++ ) { for( var i = 0, n = array_length(inputs); i < n; i++ ) {
var _in = inputs[i]; var _in = inputs[i].bypass_junc;
if(_in.bypass_junc == noone || !_in.bypass_junc.visible) continue; if(_in == noone || !_in.visible) continue;
for( var j = 0, m = array_length(_in.value_to); j < m; j++ ) { for( var j = 0, m = array_length(_in.value_to); j < m; j++ ) {
var _jto = _in.value_to[j]; var _jto = _in.value_to[j];
if(_jto.value_from != _ot || !_jto.node.active) continue; if(_jto.value_from != _in || !_jto.node.active) continue;
array_push(nodes, _jto.node); array_push(nodes, _jto.node);
} }
} }
@ -1373,7 +1373,7 @@ function Node(_x, _y, _group = noone) : __Node_Base(_x, _y) constructor {
for(var i = 0; i < array_length(inputs); i++) { for(var i = 0; i < array_length(inputs); i++) {
var _in = inputs[i]; var _in = inputs[i];
if(_in.bypass_junc == noone) continue; // if(_in.bypass_junc == noone) continue;
var _tos = _in.bypass_junc.getJunctionTo(); var _tos = _in.bypass_junc.getJunctionTo();
for( var j = 0; j < array_length(_tos); j++ ) for( var j = 0; j < array_length(_tos); j++ )

View file

@ -8,7 +8,8 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
.setVisible(true, true); .setVisible(true, true);
newInput(1, nodeValue_Path("Font", self, "")) newInput(1, nodeValue_Path("Font", self, ""))
.setDisplay(VALUE_DISPLAY.path_font); .setDisplay(VALUE_DISPLAY.path_font)
.setVisible(true, false);
newInput(2, nodeValue_Int("Size", self, 16)); newInput(2, nodeValue_Int("Size", self, 16));
@ -96,9 +97,7 @@ function Node_Text(_x, _y, _group = noone) : Node_Processor(_x, _y, _group) cons
if(!file_exists_empty(_path)) return; if(!file_exists_empty(_path)) return;
if(font != f_p0 && font_exists(font)) if(font != f_p0 && font_exists(font)) font_delete(font);
font_delete(font);
font_add_enable_aa(_aa); font_add_enable_aa(_aa);
font = font_add(_path, _size, false, false, 0, 127); font = font_add(_path, _size, false, false, 0, 127);
} }

View file

@ -2334,6 +2334,7 @@ function NodeValue(_name, _node, _connect, _type, _value, _tooltip = "") constru
if(!globalExtractable()) return noone; if(!globalExtractable()) return noone;
var _key = $"{node.getDisplayName()}_{name}"; var _key = $"{node.getDisplayName()}_{name}";
_key = string_to_var(_key);
var _glb = node.project.globalNode; var _glb = node.project.globalNode;
if(_glb.inputExist(_key)) if(_glb.inputExist(_key))
@ -2456,7 +2457,7 @@ function checkJuncConnection(from, to, params) {
var cx = round((frx + jx) / 2 + shx); var cx = round((frx + jx) / 2 + shx);
var cy = round((fry + jy) / 2 + shy); var cy = round((fry + jy) / 2 + shy);
var th = max(1, PROJECT.graphConnection.line_width * _s); var th = max(1, PROJECT.graphConnection.line_width * _s);
var hover, hovDist = max(th * 2, 6); var hover, hovDist = max(th * 2, 12);
var _fin = from.draw_line_shift_e > -1? from.draw_line_shift_e : from.drawLineIndex; var _fin = from.draw_line_shift_e > -1? from.draw_line_shift_e : from.drawLineIndex;
var _tin = to.draw_line_shift_e > -1? to.draw_line_shift_e : to.drawLineIndex; var _tin = to.draw_line_shift_e > -1? to.draw_line_shift_e : to.drawLineIndex;
@ -2509,7 +2510,7 @@ function checkJuncConnection(from, to, params) {
return hover? self : noone; return hover? self : noone;
} }
function drawJuncConnection(from, to, params, _thick = false) { function drawJuncConnection(from, to, params, _hover = 0) {
if(from == noone || to == noone) return noone; if(from == noone || to == noone) return noone;
static drawParam = { static drawParam = {
@ -2537,7 +2538,7 @@ function drawJuncConnection(from, to, params, _thick = false) {
var shy = to.draw_line_shift_y * _s; var shy = to.draw_line_shift_y * _s;
var cx = round((frx + jx) / 2 + shx); var cx = round((frx + jx) / 2 + shx);
var cy = round((fry + jy) / 2 + shy); var cy = round((fry + jy) / 2 + shy);
var th = max(1, PROJECT.graphConnection.line_width * _s) * (1 + _thick); var th = max(1, PROJECT.graphConnection.line_width * _s) * (1 + _hover);
#region draw parameters #region draw parameters
var corner = PROJECT.graphConnection.line_corner * _s; var corner = PROJECT.graphConnection.line_corner * _s;

View file

@ -382,6 +382,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
node_drag_sy = 0; node_drag_sy = 0;
node_drag_ox = 0; node_drag_ox = 0;
node_drag_oy = 0; node_drag_oy = 0;
node_drag_add = false;
selection_block = 0; selection_block = 0;
nodes_selecting = []; nodes_selecting = [];
@ -1558,9 +1559,10 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
if(connection_draw_update || pHOVER) { if(connection_draw_update || pHOVER) {
surface_set_target(connection_surface_cc); surface_set_target(connection_surface_cc);
if(connection_draw_update) { DRAW_CLEAR } if(connection_draw_update) { DRAW_CLEAR }
var hoverable = !bool(node_dragging) && pHOVER; var hoverable = pHOVER;
hoverable &= !node_dragging || node_drag_add;
connection_param.active = hoverable; connection_param.active = hoverable;
connection_param.setPos(gr_x, gr_y, graph_s, mx, my); connection_param.setPos(gr_x, gr_y, graph_s, mx, my);
connection_param.setBoundary(-64, -64, w + 64, h + 64); connection_param.setBoundary(-64, -64, w + 64, h + 64);
@ -1580,8 +1582,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
DRAW_CLEAR DRAW_CLEAR
draw_surface(connection_surface_cc, 0, 0); draw_surface(connection_surface_cc, 0, 0);
if(hov) drawJuncConnection(hov.value_from, hov, connection_param, 1 + (node_drag_add && node_dragging));
if(hov) drawJuncConnection(hov.value_from, hov, connection_param, true);
if(value_dragging && connection_draw_mouse != noone && !key_mod_press(SHIFT)) { if(value_dragging && connection_draw_mouse != noone && !key_mod_press(SHIFT)) {
var _cmx = connection_draw_mouse[0]; var _cmx = connection_draw_mouse[0];
@ -1675,14 +1676,46 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
printIf(log, $"Draw node: {get_timer() - t}"); t = get_timer(); printIf(log, $"Draw node: {get_timer() - t}"); t = get_timer();
// dragging // dragging
if(mouse_press(mb_left)) if(mouse_press(mb_left)) {
node_dragging = noone;
if(node_drag_add && node_dragging && junction_hovering != noone) {
var _jfr = junction_hovering.value_from;
var _jto = junction_hovering;
var _shy = undefined;
for( var i = 0, n = array_length(node_dragging.inputs); i < n; i++ ) {
var _inp = node_dragging.inputs[i];
if((value_bit(_inp.type) & value_bit(_jfr.type) != 0) && _inp.setFrom(_jfr)) {
_shy = _jfr.node.y;
break;
}
}
for( var i = 0, n = array_length(node_dragging.outputs); i < n; i++ ) {
if(_jto.setFrom(node_dragging.outputs[i])) {
_shy = _shy == undefined? _jto.node.y : (_shy + _jto.node.y) / 2;
break;
}
}
if(_shy != undefined) {
node_dragging.x -= node_dragging.w / 2;
node_dragging.y = _shy;
}
}
if(node_dragging) nodes_selecting = [ node_dragging ];
node_dragging = noone;
node_drag_add = false;
}
for(var i = 0; i < array_length(nodes_list); i++) for(var i = 0; i < array_length(nodes_list); i++)
nodes_list[i].groupCheck(gr_x, gr_y, graph_s, mx, my); nodes_list[i].groupCheck(gr_x, gr_y, graph_s, mx, my);
if(node_dragging && !key_mod_press(ALT)) { if(node_dragging && !key_mod_press(ALT)) {
addKeyOverlay("Dragging node(s)", [[ "Ctrl", "Disable snapping" ]]); addKeyOverlay("Dragging node(s)", [[ "Ctrl", "Disable snapping" ]]);
connection_draw_update = true;
node_surface_update = true;
var _mgx = mouse_graph_x; var _mgx = mouse_graph_x;
var _mgy = mouse_graph_y; var _mgy = mouse_graph_y;
@ -1742,7 +1775,7 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
} }
} }
if(mouse_release(mb_left)) if(!node_drag_add && mouse_release(mb_left))
node_dragging = noone; node_dragging = noone;
printIf(log, $"Drag node time : {get_timer() - t}"); t = get_timer(); printIf(log, $"Drag node time : {get_timer() - t}"); t = get_timer();
@ -1847,7 +1880,6 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
drag_locking = false; drag_locking = false;
} }
printIf(log, $"Draw selection frame : {get_timer() - t}"); t = get_timer(); printIf(log, $"Draw selection frame : {get_timer() - t}"); t = get_timer();
} }
@ -3255,6 +3287,23 @@ function Panel_Graph(project = PROJECT) : PanelContent() constructor {
return false; return false;
} }
function selectDragNode(_node, _add = false) {
nodes_selecting = [ _node ];
node_dragging = _node;
_node.x = mouse_graph_x
_node.y = mouse_graph_y
node_drag_mx = mouse_graph_x;
node_drag_my = mouse_graph_y;
node_drag_sx = _node.x;
node_drag_sy = _node.y;
node_drag_ox = -1;
node_drag_oy = -1;
node_drag_add = _add;
}
static checkDropItem = function() { // static checkDropItem = function() { //
var node = noone; var node = noone;

View file

@ -1133,29 +1133,41 @@ function Panel_Inspector() : PanelContent() constructor {
array_push(_menuItem, -1); array_push(_menuItem, -1);
} }
array_push(_menuItem, jun.expUse? menu_junc_expression_dis : menu_junc_expression_ena);
if(jun.globalExtractable()) array_push(_menuItem, menu_junc_extract_global);
if(_inp) array_push(_menuItem, menu_junc_bypass_toggle); if(_inp) array_push(_menuItem, menu_junc_bypass_toggle);
array_push(_menuItem, jun.expUse? menu_junc_expression_dis : menu_junc_expression_ena);
if(jun.globalExtractable()) {
array_push(_menuItem, menuItemShelf(__txtx("panel_inspector_use_global", "Use Globalvar"), function(_dat) /*=>*/ {
var arr = [];
for( var i = 0, n = array_length(PROJECT.globalNode.inputs); i < n; i++ ) {
var _glInp = PROJECT.globalNode.inputs[i];
if(!typeCompatible(_glInp.type, __dialog_junction.type)) continue;
array_push(arr, menuItem(_glInp.name, function(d) /*=>*/ { __dialog_junction.setExpression(d.name); }, noone, noone, noone, { name : _glInp.name }));
}
return submenuCall(_dat, arr);
}));
array_push(_menuItem, menu_junc_extract_global);
}
array_push(_menuItem, -1, menu_junc_copy); array_push(_menuItem, -1, menu_junc_copy);
if(_inp) array_push(_menuItem, menu_junc_paste); if(_inp) array_push(_menuItem, menu_junc_paste);
if(_inp && jun.extract_node != "") { if(_inp && jun.extract_node != "") {
if(is_array(jun.extract_node)) { if(is_array(jun.extract_node)) {
var ext = menuItemShelf(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) { array_push(_menuItem, menuItemShelf(__txtx("panel_inspector_extract_multiple", "Extract to..."), function(_dat) /*=>*/ {
var arr = []; var arr = [];
for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) { for(var i = 0; i < array_length(__dialog_junction.extract_node); i++) {
var _rec = __dialog_junction.extract_node[i]; var _rec = __dialog_junction.extract_node[i];
var _nod = ALL_NODES[$ _rec]; array_push(arr, menuItem(ALL_NODES[$ _rec].name,
function(d) /*=>*/ { __dialog_junction.extractNode(d.name); }, noone, noone, noone, { name : _rec }));
array_push(arr, menuItem(_nod.name, function(_dat) /*=>*/ { __dialog_junction.extractNode(_dat.name); }, noone, noone, noone, { name : _rec }));
} }
return submenuCall(_dat, arr); return submenuCall(_dat, arr);
}); }));
array_push(_menuItem, ext);
} else } else array_push(_menuItem, menu_junc_extract);
array_push(_menuItem, menu_junc_extract);
} }
var dia = menuCall("inspector_value_menu", _menuItem); var dia = menuCall("inspector_value_menu", _menuItem);

View file

@ -72,7 +72,7 @@
registerFunction("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload ).setMenu("reload_theme", ) registerFunction("", "Reload theme", vk_f10, MOD_KEY.ctrl | MOD_KEY.shift, global_theme_reload ).setMenu("reload_theme", )
registerFunction("", "Addons Menu", "", MOD_KEY.none, function(_dat) /*=>*/ { registerFunction("", "Addons", "", MOD_KEY.none, function(_dat) /*=>*/ {
var arr = [ var arr = [
MENU_ITEMS.addons, MENU_ITEMS.addons,
menuItem(__txtx("panel_menu_addons_key", "Key displayer"), function() /*=>*/ { if(instance_exists(addon_key_displayer)) return; instance_create_depth(0, 0, 0, addon_key_displayer); }), menuItem(__txtx("panel_menu_addons_key", "Key displayer"), function() /*=>*/ { if(instance_exists(addon_key_displayer)) return; instance_create_depth(0, 0, 0, addon_key_displayer); }),

View file

@ -123,6 +123,12 @@ function Panel_Preference() : PanelContent() constructor {
slider(0, 1, 0.01, function(val) /*=>*/ { PREFERENCES.keyboard_repeat_speed = val; PREF_SAVE(); }) slider(0, 1, 0.01, function(val) /*=>*/ { PREFERENCES.keyboard_repeat_speed = val; PREF_SAVE(); })
)); ));
ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_keyboard_check_sweep", "Keyboard check sweep"),
"keyboard_check_sweep",
new checkBox(function() /*=>*/ { PREFERENCES.keyboard_check_sweep = !PREFERENCES.keyboard_check_sweep; PREF_SAVE(); })
));
ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference( ds_list_add(pref_global, new __Panel_Linear_Setting_Item_Preference(
__txtx("pref_expand_hovering_panel", "Expand hovering panel"), __txtx("pref_expand_hovering_panel", "Expand hovering panel"),
"expand_hover", "expand_hover",

View file

@ -50,6 +50,8 @@
PREFERENCES.keyboard_repeat_start = 0.50; PREFERENCES.keyboard_repeat_start = 0.50;
PREFERENCES.keyboard_repeat_speed = 0.10; PREFERENCES.keyboard_repeat_speed = 0.10;
PREFERENCES.keyboard_double_delay = 0.25; PREFERENCES.keyboard_double_delay = 0.25;
PREFERENCES.keyboard_check_sweep = true;
PREFERENCES.keyboard_capture_raw = true;
PREFERENCES.file_watcher_delay = 0.1; PREFERENCES.file_watcher_delay = 0.1;
@ -121,7 +123,9 @@
#endregion #endregion
#region //////////////////////////////////////////////////////////////////////// NODES ///////////////////////////////////////////////////////////////////////// #region //////////////////////////////////////////////////////////////////////// NODES /////////////////////////////////////////////////////////////////////////
PREFERENCES.node_add_select = true;
PREFERENCES.node_param_show = false; PREFERENCES.node_param_show = false;
PREFERENCES.node_param_width = 192; PREFERENCES.node_param_width = 192;
PREFERENCES.node_3d_preview_size = 256; PREFERENCES.node_3d_preview_size = 256;