Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue #1383: Generic autofocus on event creation with button #1573

Merged
merged 11 commits into from
May 22, 2023

Conversation

CristianRos
Copy link
Contributor

I added this 3 properties to the event base class: created_by_button, autofocus_field_index and autofocus_relative_path.

I created a flag created_by_button so the build_editor() function in event_block script knows when it's being created with a button or not. Setting it up to true before calling add_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 of autofocus_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 with autofocus_relative_path

Now we can give autofocus to any event field with something like:
image
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!

@Jowan-Spooner
Copy link
Collaborator

Looks great. Will try to test it later and merge it then!

@Jowan-Spooner Jowan-Spooner merged commit 7a09143 into dialogic-godot:main May 22, 2023
@coppolaemilio
Copy link
Collaborator

@CristianRos I love it! Thank you so much for the contribution 🥳

@CristianRos CristianRos deleted the autofocus-text-event branch May 23, 2023 15:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Autofocus text editor when Text event is created
3 participants