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

Add keyboard shortcut for last annotation #950

Open
wants to merge 7 commits into
base: master
Choose a base branch
from

Conversation

lehecht
Copy link
Contributor

@lehecht lehecht commented Oct 14, 2024

  • Add shortcut to videos
  • Add shortcut to images
  • Add shortcut to the manual

Closes #499.

@mzur
Copy link
Member

mzur commented Oct 14, 2024

I saw that you added a new controller for this. The original idea was to just take the annotation with the highest ID and select it. This does not require a controller etc.

@lehecht
Copy link
Contributor Author

lehecht commented Oct 14, 2024

I saw that you added a new controller for this. The original idea was to just take the annotation with the highest ID and select it. This does not require a controller etc.

Sorry, I thought that the annotation list could not be up-to-date at some point, but I was wrong. I reverted all my changes.

@lehecht lehecht requested a review from mzur October 14, 2024 13:30
@lehecht lehecht marked this pull request as ready for review October 14, 2024 13:32
Copy link
Member

@mzur mzur left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry to be this nitpicky about such a small change again but, well, that's my job 😁

Is there a specific reason why the shortcut is handled by the annotationCanvas/videoScreen? It could also be handled directly in the annotatorContainer/videoContainer. Then there is no need to pass and handle an extra event.

Also I'm ambivalent about Ctrl+l. The l shortcut is already associated with the attach/swap tool. While this action is also about "selecting something", it's not directly related to the tool. Maybe we find an unused key and can add the shortcut without modifier (Ctrl)?

Finally, the new shortcut must be added to the manual.

Comment on lines +598 to +599
lastAnnotation.selected = true;
remainingAnnotations.map(a => a.selected = false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use handleSelectAnnotation() so there are not too many different places that handle selecting of annotations.

Suggested change
lastAnnotation.selected = true;
remainingAnnotations.map(a => a.selected = false);
this.handleSelectAnnotation(lastAnnotation);

Comment on lines +679 to +680
lastAnnotation.selected = true;
remainingAnnotations.map(a => a.selected = false);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have you tried this and it works? When an annotation is selected (e.g. in the sidebar) the tool should seek the video to the start of the annotation. In the videoContainer annotation.selected is then set to this time. Same as above, it should work fine if you reuse selectAnnotations():

Suggested change
lastAnnotation.selected = true;
remainingAnnotations.map(a => a.selected = false);
this.selectAnnotations([lastAnnotation], [], lastAnnotation.startFrame);

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! When I tested it, I created multiple annotations in the same frame, which is why I didn't notice that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you leave the second parameter empty on purpose? Because this causes the last annotation only to be selected but not to seek the video, if another annotation was already selected on the timeline.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. I just wanted to avoid selectAnnotation() because this can have unexpected side effects with attaching or swapping labels. You should use:

this.selectAnnotations([lastAnnotation], this.selectedAnnotations, lastAnnotation.startFrame);

@lehecht
Copy link
Contributor Author

lehecht commented Oct 15, 2024

@mzur

Is there a specific reason why the shortcut is handled by the annotationCanvas/videoScreen?

Because all keyboard events are handled in these components and transfer the events to the parent components. So I just copied what was already there, but it is no problem to change that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Select last annotation keyboard shortcut
2 participants