@@ -135,7 +135,7 @@ func process_port_click(pressed : bool):
135135 return
136136
137137
138- func _input (event : InputEvent ) -> void :
138+ func _input (event : InputEvent ) -> void :
139139 # Handle node grab
140140 if has_grab :
141141 var selected_nodes := get_selected_nodes ()
@@ -156,6 +156,11 @@ func _input(event: InputEvent) -> void:
156156 if get_nodes_under_mouse ().is_empty ():
157157 node .set_deferred ("selected" , true )
158158
159+ # Grab graph focus for quick bar shortcuts to work properly
160+ # (i.e. returning to graph after interacting with other panels)
161+ if Rect2 (Vector2 .ZERO , size ).has_point (get_local_mouse_position ()):
162+ if event is InputEventKey and event .unicode >= KEY_0 and event .unicode <= KEY_9 and event .pressed :
163+ grab_focus ()
159164
160165func _gui_input (event ) -> void :
161166 if (
@@ -299,6 +304,9 @@ func _gui_input(event) -> void:
299304 has_grab = true
300305 KEY_ESCAPE :
301306 has_grab = false
307+ _ when event .unicode >= KEY_0 and event .unicode <= KEY_9 :
308+ if get_nodes_under_mouse ().is_empty ():
309+ quick_bar_shortcuts (event )
302310 match event .get_keycode ():
303311 KEY_SHIFT , KEY_CTRL , KEY_ALT :
304312 var found_tip : bool = false
@@ -1836,6 +1844,22 @@ func _get_connection_line(from : Vector2, to : Vector2) -> PackedVector2Array:
18361844 _ :
18371845 return points
18381846
1847+ func quick_bar_shortcuts (event : InputEventKey ) -> void :
1848+ if not Rect2 (Vector2 .ZERO , size ).has_point (get_local_mouse_position ()):
1849+ return
1850+ var key_num : int = event .unicode - KEY_0 - 1
1851+ key_num = 9 if key_num == - 1 else key_num
1852+
1853+ var library_manager : Node = get_node ("/root/MainWindow/NodeLibraryManager" )
1854+ var quick_button_key : String = "quick_button_%d " % [key_num ]
1855+
1856+ if mm_globals .config .has_section_key ("library" , quick_button_key ):
1857+ var config : String = mm_globals .config .get_value ("library" , quick_button_key )
1858+ if config != "" :
1859+ var library_item : Dictionary = library_manager .get_item (config )
1860+ if library_item != null :
1861+ do_paste (library_item .item )
1862+
18391863func colorize_nodes () -> void :
18401864 var nodes : Array [GraphElement ]
18411865 for n in get_children ():
0 commit comments