fix #40556: focus lost after change duration of note on offbeat #1532
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 looked at the git history and mostly understand what is going on here. I see that code was added to remember the selected element and then restore it later. The code was simply not added to the case of notes on offbeats (or more generally, whatever is actually being tested for in https://github.com/musescore/MuseScore/blame/master/libmscore/cmd.cpp#L1007).
My change here seems totally safe, and does fix the issue I see now. I simply restore the selection to selElement in the off-the-beat case just as we do in the on-the-beat case.
What I don't know is if there are also situations in this off-the-beat case where we should still be selecting "oc" like we do at https://github.com/musescore/MuseScore/blame/master/libmscore/cmd.cpp#L1024 in the on-the-beat case, and like we used to do at https://github.com/musescore/MuseScore/blame/master/libmscore/cmd.cpp#L1049 in the off-the-beat case before that line was commented out. That's because I don't know how to hit this line in the on-the-beat case, so I can't see if we need it here in the off-the-beat case too.
What I can see is, in the on-the-beat case, we only get here if "oc" is not zero, but in the off-the-beat case, it could be zero. So if we do choose to select it, it should probably as "else if (oc)" not just "else".