diff --git a/addons/dialogic/Editor/Events/EventBlock/event_block.gd b/addons/dialogic/Editor/Events/EventBlock/event_block.gd index 37c21bb1c..c7d716d7c 100644 --- a/addons/dialogic/Editor/Events/EventBlock/event_block.gd +++ b/addons/dialogic/Editor/Events/EventBlock/event_block.gd @@ -287,6 +287,11 @@ func build_editor(build_header:bool = true, build_body:bool = false) -> void: field_list.append({'node': left_label, 'condition':p.condition, 'location':p.location}) if right_label: field_list.append({'node': right_label, 'condition':p.condition, 'location':p.location}) + + ### -------------------------------------------------------------------- + ### 4. GETTING THE PATH OF THE FIELD WE WANT TO FOCUS (in case we want) + if resource.created_by_button and p.display_info.get('autofocus', false) and editor_node.has_method('take_autofocus'): + editor_node.take_autofocus() if build_body: # has_body_content = true diff --git a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd index 9b83dca9d..a516f65e3 100644 --- a/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd +++ b/addons/dialogic/Editor/Events/Fields/ComplexPicker.gd @@ -88,6 +88,9 @@ func _exit_tree(): event_resource = null +func take_autofocus(): + %Search.grab_focus() + ################################################################################ ## SEARCH & SUGGESTION POPUP ################################################################################ diff --git a/addons/dialogic/Editor/Events/Fields/MultilineText.gd b/addons/dialogic/Editor/Events/Fields/MultilineText.gd index bc765cfb1..a8b21a1cc 100644 --- a/addons/dialogic/Editor/Events/Fields/MultilineText.gd +++ b/addons/dialogic/Editor/Events/Fields/MultilineText.gd @@ -15,3 +15,5 @@ func text_changed(value = ""): func set_value(value): $TextEdit.text = str(value) +func take_autofocus(): + $TextEdit.grab_focus() diff --git a/addons/dialogic/Editor/Events/Fields/Number.gd b/addons/dialogic/Editor/Events/Fields/Number.gd index 44b04cefe..6d0e97062 100644 --- a/addons/dialogic/Editor/Events/Fields/Number.gd +++ b/addons/dialogic/Editor/Events/Fields/Number.gd @@ -78,3 +78,7 @@ func _on_value_text_submitted(new_text): func _on_value_focus_exited(): _on_value_text_submitted($Value.text) + + +func take_autofocus(): + $Value.grab_focus() diff --git a/addons/dialogic/Editor/Events/Fields/SinglelineText.gd b/addons/dialogic/Editor/Events/Fields/SinglelineText.gd index 1c60a4555..4bd5010b1 100644 --- a/addons/dialogic/Editor/Events/Fields/SinglelineText.gd +++ b/addons/dialogic/Editor/Events/Fields/SinglelineText.gd @@ -24,3 +24,6 @@ func _on_text_changed(value := "") -> void: func set_value(value:String) -> void: text = str(value) + +func take_autofocus(): + grab_focus() diff --git a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd index 4ba418daa..5872badf9 100644 --- a/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd +++ b/addons/dialogic/Editor/TimelineEditor/VisualEditor/timeline_editor_visual.gd @@ -686,6 +686,8 @@ func _add_event_button_pressed(event_resource:DialogicEvent): var resource := event_resource.duplicate() resource._load_custom_defaults() + resource.created_by_button = true + TimelineUndoRedo.create_action("[D] Add "+event_resource.event_name+" event.") if event_resource.can_contain_events: TimelineUndoRedo.add_do_method(add_event_with_end_branch.bind(resource, at_index, true, true)) @@ -695,6 +697,8 @@ func _add_event_button_pressed(event_resource:DialogicEvent): TimelineUndoRedo.add_undo_method(remove_events_at_index.bind(at_index, 1)) TimelineUndoRedo.commit_action() + resource.created_by_button = false + something_changed() scroll_to_piece(at_index) indent_events() diff --git a/addons/dialogic/Modules/Character/event_character.gd b/addons/dialogic/Modules/Character/event_character.gd index 447bce0c9..518a11248 100644 --- a/addons/dialogic/Modules/Character/event_character.gd +++ b/addons/dialogic/Modules/Character/event_character.gd @@ -404,7 +404,8 @@ func build_event_editor() -> void: {'empty_text' : 'Character', 'file_extension' : '.dch', 'suggestions_func' : get_character_suggestions, - 'icon' : load("res://addons/dialogic/Editor/Images/Resources/character.svg")}) + 'icon' : load("res://addons/dialogic/Editor/Images/Resources/character.svg"), + 'autofocus' : true}) add_header_button('', _on_character_edit_pressed, 'Edit character', ["ExternalLink", "EditorIcons"], 'character != null and _character_from_directory != "--All--"') add_header_edit('portrait', ValueType.ComplexPicker, '', '', diff --git a/addons/dialogic/Modules/Choice/event_choice.gd b/addons/dialogic/Modules/Choice/event_choice.gd index f53069ca2..705c778f9 100644 --- a/addons/dialogic/Modules/Choice/event_choice.gd +++ b/addons/dialogic/Modules/Choice/event_choice.gd @@ -132,7 +132,7 @@ func _get_property_original_translation(property:String) -> String: ################################################################################ func build_event_editor() -> void: - add_header_edit("text", ValueType.SinglelineText) + add_header_edit("text", ValueType.SinglelineText, '','', {'autofocus':true}) add_body_edit("condition", ValueType.Condition, 'if ') add_body_edit("else_action", ValueType.FixedOptionSelector, 'else ', '', { 'selector_options': [ diff --git a/addons/dialogic/Modules/Comment/event_comment.gd b/addons/dialogic/Modules/Comment/event_comment.gd index 9afedeb08..a939b81b7 100644 --- a/addons/dialogic/Modules/Comment/event_comment.gd +++ b/addons/dialogic/Modules/Comment/event_comment.gd @@ -56,4 +56,4 @@ func is_valid_event(string:String) -> bool: ################################################################################ func build_event_editor(): - add_header_edit('text', ValueType.SinglelineText, '#') + add_header_edit('text', ValueType.SinglelineText, '#','',{'autofocus':true}) diff --git a/addons/dialogic/Modules/Jump/event_jump.gd b/addons/dialogic/Modules/Jump/event_jump.gd index c905d3631..26bf830b3 100644 --- a/addons/dialogic/Modules/Jump/event_jump.gd +++ b/addons/dialogic/Modules/Jump/event_jump.gd @@ -93,7 +93,8 @@ func build_event_editor(): 'file_extension': '.dtl', 'suggestions_func': get_timeline_suggestions, 'editor_icon': ["TripleBar", "EditorIcons"], - 'empty_text': '(this timeline)' + 'empty_text': '(this timeline)', + 'autofocus':true }) add_header_edit("label_name", ValueType.SinglelineText, "at", '', {'placeholder':'the beginning'}) add_body_edit("return_after", ValueType.Bool, "Return to this spot after completed?") diff --git a/addons/dialogic/Modules/Jump/event_label.gd b/addons/dialogic/Modules/Jump/event_label.gd index 28502d28f..7e5a7abf1 100644 --- a/addons/dialogic/Modules/Jump/event_label.gd +++ b/addons/dialogic/Modules/Jump/event_label.gd @@ -56,4 +56,4 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('name', ValueType.SinglelineText) + add_header_edit('name', ValueType.SinglelineText, '', '', {'autofocus':true}) diff --git a/addons/dialogic/Modules/Signal/event_signal.gd b/addons/dialogic/Modules/Signal/event_signal.gd index 8553468b5..24fbb7c3b 100644 --- a/addons/dialogic/Modules/Signal/event_signal.gd +++ b/addons/dialogic/Modules/Signal/event_signal.gd @@ -51,4 +51,5 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('argument', ValueType.SinglelineText, 'Emit "signal_event" signal with argument') + add_header_edit('argument', ValueType.SinglelineText, + 'Emit "signal_event" signal with argument', '', {'autofocus':true}) diff --git a/addons/dialogic/Modules/Text/event_text.gd b/addons/dialogic/Modules/Text/event_text.gd index ff352a144..42dbc8e53 100644 --- a/addons/dialogic/Modules/Text/event_text.gd +++ b/addons/dialogic/Modules/Text/event_text.gd @@ -239,7 +239,7 @@ func build_event_editor(): 'placeholder' : "(Don't change)", 'icon' : load("res://addons/dialogic/Editor/Images/Resources/portrait.svg")}, 'character != null and !has_no_portraits()') - add_body_edit('text', ValueType.MultilineText) + add_body_edit('text', ValueType.MultilineText, '', '', {'autofocus' = true}) func do_any_characters_exist() -> bool: return !DialogicUtil.list_resources_of_type(".dch").is_empty() diff --git a/addons/dialogic/Modules/Wait/event_wait.gd b/addons/dialogic/Modules/Wait/event_wait.gd index 0fbfeb20a..87d7c24c4 100644 --- a/addons/dialogic/Modules/Wait/event_wait.gd +++ b/addons/dialogic/Modules/Wait/event_wait.gd @@ -61,6 +61,6 @@ func get_shortcode_parameters() -> Dictionary: ################################################################################ func build_event_editor(): - add_header_edit('time', ValueType.Float) + add_header_edit('time', ValueType.Float, '','', {'autofocus':true}) add_header_label('seconds.') add_body_edit('hide_text', ValueType.Bool, 'Hide text box:') diff --git a/addons/dialogic/Resources/event.gd b/addons/dialogic/Resources/event.gd index 25c92aea3..b42a65e37 100644 --- a/addons/dialogic/Resources/event.gd +++ b/addons/dialogic/Resources/event.gd @@ -67,6 +67,8 @@ var disable_editor_button: bool = false var expand_by_default : bool = true ## The URL to open when right_click>Documentation is selected var help_page_path : String = "" +## Is the event block created by a button? +var created_by_button : bool = false ## Reference to the node, that represents this event. Only works while in visual editor mode. ## Use with care.