@@ -3921,8 +3921,13 @@ void AnimationTrackEditor::remove_track_edit_plugin(const Ref<AnimationTrackEdit
39213921}
39223922
39233923void AnimationTrackEditor::set_animation (const Ref<Animation> &p_anim, bool p_read_only) {
3924- if (animation != p_anim && _get_track_selected () >= 0 ) {
3925- track_edits[_get_track_selected ()]->release_focus ();
3924+ if (animation != p_anim) {
3925+ for (int i = 0 ; i < track_edits.size (); i++) {
3926+ if (track_edits[i]->has_focus ()) {
3927+ track_edits[i]->release_focus ();
3928+ break ;
3929+ }
3930+ }
39263931 }
39273932 if (animation.is_valid ()) {
39283933 animation->disconnect_changed (callable_mp (this , &AnimationTrackEditor::_animation_changed));
@@ -4191,7 +4196,11 @@ void AnimationTrackEditor::_animation_track_remove_request(int p_track, Ref<Anim
41914196void AnimationTrackEditor::_track_grab_focus (int p_track) {
41924197 // Don't steal focus if not working with the track editor.
41934198 if (Object::cast_to<AnimationTrackEdit>(get_viewport ()->gui_get_focus_owner ())) {
4194- track_edits[p_track]->grab_focus ();
4199+ for (int i = 0 ; i < track_edits.size (); i++) {
4200+ if (track_edits[i]->get_track () == p_track) {
4201+ track_edits[i]->grab_focus ();
4202+ }
4203+ }
41954204 }
41964205}
41974206
@@ -5704,7 +5713,7 @@ void AnimationTrackEditor::_timeline_value_changed(double) {
57045713int AnimationTrackEditor::_get_track_selected () {
57055714 for (int i = 0 ; i < track_edits.size (); i++) {
57065715 if (track_edits[i]->has_focus ()) {
5707- return i ;
5716+ return track_edits[i]-> get_track () ;
57085717 }
57095718 }
57105719
0 commit comments