Fix issue #1383: Generic autofocus on event creation with button #1573
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I added this 3 properties to the event base class:
created_by_button
,autofocus_field_index
andautofocus_relative_path
.I created a flag
created_by_button
so thebuild_editor()
function in event_block script knows when it's being created with a button or not. Setting it up to true before callingadd_event_node()
inside_add_event_button_pressed()
in the timeline_editor_visual script, and defaulting it back to false after the node is created.Then when
build_editor()
is creating fields we check if the new one it's the right one by index and get it's path to grab the focus. We know which one it is because ofautofocus_field_index
(-1 being the default index for none). Additionally if we need to access a child of the field we can provide a relative path withautofocus_relative_path
Now we can give autofocus to any event field with something like:
Which are the lines of code I added to the event_text script
If you want me to add autofocus to any other event, or to change anything else let me know!