@@ -407,21 +407,25 @@ void GraphNode::gui_input(const Ref<InputEvent> &p_event) {
407
407
}
408
408
409
409
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
+ }
423
426
}
424
- } else if (p_event->is_action (" ui_cancel" , true )) {
427
+ }
428
+ if (p_event->is_action (" ui_cancel" , true )) {
425
429
GraphEdit *graph = Object::cast_to<GraphEdit>(get_parent ());
426
430
if (graph && graph->is_keyboard_connecting ()) {
427
431
graph->force_connection_drag_end ();
@@ -664,9 +668,18 @@ void GraphNode::_notification(int p_what) {
664
668
}
665
669
666
670
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 ));
670
683
}
671
684
672
685
// Draw slot stylebox.
@@ -1180,6 +1193,23 @@ Vector<int> GraphNode::get_allowed_size_flags_vertical() const {
1180
1193
return flags;
1181
1194
}
1182
1195
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
+
1183
1213
void GraphNode::_bind_methods () {
1184
1214
ClassDB::bind_method (D_METHOD (" set_title" , " title" ), &GraphNode::set_title);
1185
1215
ClassDB::bind_method (D_METHOD (" get_title" ), &GraphNode::get_title);
@@ -1220,6 +1250,9 @@ void GraphNode::_bind_methods() {
1220
1250
ClassDB::bind_method (D_METHOD (" set_ignore_invalid_connection_type" , " ignore" ), &GraphNode::set_ignore_invalid_connection_type);
1221
1251
ClassDB::bind_method (D_METHOD (" is_ignoring_valid_connection_type" ), &GraphNode::is_ignoring_valid_connection_type);
1222
1252
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
+
1223
1256
ClassDB::bind_method (D_METHOD (" get_input_port_count" ), &GraphNode::get_input_port_count);
1224
1257
ClassDB::bind_method (D_METHOD (" get_input_port_position" , " port_idx" ), &GraphNode::get_input_port_position);
1225
1258
ClassDB::bind_method (D_METHOD (" get_input_port_type" , " port_idx" ), &GraphNode::get_input_port_type);
@@ -1236,6 +1269,7 @@ void GraphNode::_bind_methods() {
1236
1269
1237
1270
ADD_PROPERTY (PropertyInfo (Variant::STRING, " title" ), " set_title" , " get_title" );
1238
1271
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" );
1239
1273
1240
1274
ADD_SIGNAL (MethodInfo (" slot_updated" , PropertyInfo (Variant::INT, " slot_index" )));
1241
1275
ADD_SIGNAL (MethodInfo (" slot_sizes_changed" ));
0 commit comments