@@ -407,21 +407,25 @@ void GraphNode::gui_input(const Ref<InputEvent> &p_event) {
407407 }
408408
409409 if (p_event->is_pressed () && slot_count > 0 ) {
410- if (p_event->is_action (" ui_up" , true )) {
411- selected_slot--;
412- if (selected_slot < 0 ) {
413- selected_slot = -1 ;
414- } else {
415- accept_event ();
416- }
417- } else if (p_event->is_action (" ui_down" , true )) {
418- selected_slot++;
419- if (selected_slot >= slot_count) {
420- selected_slot = -1 ;
421- } else {
422- accept_event ();
410+ bool ac_enabled = get_tree () && get_tree ()->is_accessibility_enabled ();
411+ if ((ac_enabled && slots_focus_mode == Control::FOCUS_ACCESSIBILITY) || slots_focus_mode == Control::FOCUS_ALL) {
412+ if (p_event->is_action (" ui_up" , true )) {
413+ selected_slot--;
414+ if (selected_slot < 0 ) {
415+ selected_slot = -1 ;
416+ } else {
417+ accept_event ();
418+ }
419+ } else if (p_event->is_action (" ui_down" , true )) {
420+ selected_slot++;
421+ if (selected_slot >= slot_count) {
422+ selected_slot = -1 ;
423+ } else {
424+ accept_event ();
425+ }
423426 }
424- } else if (p_event->is_action (" ui_cancel" , true )) {
427+ }
428+ if (p_event->is_action (" ui_cancel" , true )) {
425429 GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent ());
426430 if (graph && graph->is_keyboard_connecting ()) {
427431 graph->force_connection_drag_end ();
@@ -664,9 +668,18 @@ void GraphNode::_notification(int p_what) {
664668 }
665669
666670 if (slot_index == selected_slot) {
667- Size2i port_sz = theme_cache.port ->get_size ();
668- draw_style_box (sb_slot_selected, Rect2i (port_h_offset - port_sz.x , slot_y_cache[E.key ] + sb_panel->get_margin (SIDE_TOP) - port_sz.y , port_sz.x * 2 , port_sz.y * 2 ));
669- draw_style_box (sb_slot_selected, Rect2i (get_size ().x - port_h_offset - port_sz.x , slot_y_cache[E.key ] + sb_panel->get_margin (SIDE_TOP) - port_sz.y , port_sz.x * 2 , port_sz.y * 2 ));
671+ Ref<Texture2D> port_icon = slot.custom_port_icon_left ;
672+ if (port_icon.is_null ()) {
673+ port_icon = theme_cache.port ;
674+ }
675+ Size2i port_sz = port_icon->get_size () + sb_slot_selected->get_minimum_size ();
676+ draw_style_box (sb_slot_selected, Rect2i (port_h_offset - port_sz.x * 0.5 , slot_y_cache[E.key ] - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
677+ port_icon = slot.custom_port_icon_right ;
678+ if (port_icon.is_null ()) {
679+ port_icon = theme_cache.port ;
680+ }
681+ port_sz = port_icon->get_size () + sb_slot_selected->get_minimum_size ();
682+ draw_style_box (sb_slot_selected, Rect2i (get_size ().x - port_h_offset - port_sz.x * 0.5 , slot_y_cache[E.key ] - port_sz.y * 0.5 , port_sz.x , port_sz.y ));
670683 }
671684
672685 // Draw slot stylebox.
@@ -1180,6 +1193,23 @@ Vector<int> GraphNode::get_allowed_size_flags_vertical() const {
11801193 return flags;
11811194}
11821195
1196+ void GraphNode::set_slots_focus_mode (Control::FocusMode p_focus_mode) {
1197+ if (slots_focus_mode == p_focus_mode) {
1198+ return ;
1199+ }
1200+ ERR_FAIL_COND ((int )p_focus_mode < 1 || (int )p_focus_mode > 3 );
1201+
1202+ slots_focus_mode = p_focus_mode;
1203+ if (slots_focus_mode == Control::FOCUS_CLICK && selected_slot > -1 ) {
1204+ selected_slot = -1 ;
1205+ queue_redraw ();
1206+ }
1207+ }
1208+
1209+ Control::FocusMode GraphNode::get_slots_focus_mode () const {
1210+ return slots_focus_mode;
1211+ }
1212+
11831213void GraphNode::_bind_methods () {
11841214 ClassDB::bind_method (D_METHOD (" set_title" , " title" ), &GraphNode::set_title);
11851215 ClassDB::bind_method (D_METHOD (" get_title" ), &GraphNode::get_title);
@@ -1220,6 +1250,9 @@ void GraphNode::_bind_methods() {
12201250 ClassDB::bind_method (D_METHOD (" set_ignore_invalid_connection_type" , " ignore" ), &GraphNode::set_ignore_invalid_connection_type);
12211251 ClassDB::bind_method (D_METHOD (" is_ignoring_valid_connection_type" ), &GraphNode::is_ignoring_valid_connection_type);
12221252
1253+ ClassDB::bind_method (D_METHOD (" set_slots_focus_mode" , " focus_mode" ), &GraphNode::set_slots_focus_mode);
1254+ ClassDB::bind_method (D_METHOD (" get_slots_focus_mode" ), &GraphNode::get_slots_focus_mode);
1255+
12231256 ClassDB::bind_method (D_METHOD (" get_input_port_count" ), &GraphNode::get_input_port_count);
12241257 ClassDB::bind_method (D_METHOD (" get_input_port_position" , " port_idx" ), &GraphNode::get_input_port_position);
12251258 ClassDB::bind_method (D_METHOD (" get_input_port_type" , " port_idx" ), &GraphNode::get_input_port_type);
@@ -1236,6 +1269,7 @@ void GraphNode::_bind_methods() {
12361269
12371270 ADD_PROPERTY (PropertyInfo (Variant::STRING, " title" ), " set_title" , " get_title" );
12381271 ADD_PROPERTY (PropertyInfo (Variant::BOOL, " ignore_invalid_connection_type" ), " set_ignore_invalid_connection_type" , " is_ignoring_valid_connection_type" );
1272+ ADD_PROPERTY (PropertyInfo (Variant::INT, " slots_focus_mode" , PROPERTY_HINT_ENUM, " Click:1,All:2,Accessibility:3" ), " set_slots_focus_mode" , " get_slots_focus_mode" );
12391273
12401274 ADD_SIGNAL (MethodInfo (" slot_updated" , PropertyInfo (Variant::INT, " slot_index" )));
12411275 ADD_SIGNAL (MethodInfo (" slot_sizes_changed" ));
0 commit comments