Skip to content

Commit a18dabb

Browse files
Implement focus() function for EventParts and use it on Text Event (#813)
This new function (focus()) is called when an event is newly created on all the direct EventParts of the event (body/header). This allows them to do anything they would like. It' s not called when the timeline is loaded. This PR also implements this on the TextAndVoicePicker and it's sub-event-part the TextEditor to make it focus the TextEdit when you create the event. This fixes #811
1 parent 5400f62 commit a18dabb

File tree

5 files changed

+19
-0
lines changed

5 files changed

+19
-0
lines changed

addons/dialogic/Editor/Events/Parts/EventPart.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,9 @@ func load_data(data:Dictionary):
3636
func get_preview_text():
3737
return ''
3838

39+
# to be overwritten by the body-parts if some kind of focus (on event creation) is wanted
40+
func focus():
41+
pass
3942

4043
# has to be called everytime the data got changed
4144
func data_changed():

addons/dialogic/Editor/Events/Parts/Text/EventPart_TextAndVoicePicker.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,3 +50,6 @@ func _on_voice_editor_data_changed(data) -> void:
5050
voice_editor.visible = use_voices()
5151
# informs the parent
5252
data_changed()
53+
54+
func focus():
55+
text_editor.focus()

addons/dialogic/Editor/Events/Parts/Text/EventPart_TextEditor.gd

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,3 +122,6 @@ func _on_TextEdit_focus_exited():
122122
# Remove text selection to visually notify the user that the text will not
123123
# be copied if they use a hotkey like CTRL + C
124124
$TextEdit.deselect()
125+
126+
func focus():
127+
$TextEdit.grab_focus()

addons/dialogic/Editor/Events/Templates/EventBlock.gd

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,12 @@ func visual_deselect():
6464
func load_data(data):
6565
event_data = data
6666

67+
# called to inform event parts, that a focus is wanted
68+
func focus():
69+
if get_header():
70+
get_header().focus()
71+
if get_body():
72+
get_body().focus()
6773

6874
func get_body():
6975
return body_node

addons/dialogic/Editor/TimelineEditor/TimelineEditor.gd

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,10 @@ func create_event(event_id: String, data: Dictionary = {'no-data': true} , inden
832832
# Indent on create
833833
if indent:
834834
indent_events()
835+
836+
if not building_timeline:
837+
piece.focus()
838+
835839
return piece
836840

837841

0 commit comments

Comments
 (0)