-
Notifications
You must be signed in to change notification settings - Fork 25
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 mouse event listener with selection box feature #290
Conversation
We needed to change SelectableState to keep track of when the selection box is active in order to make this information available for other components.
The props contained in some cases the selectionBoxActive attribute. When passing the props object to svg, an error was shown in the console saying that selectionBoxActive is not an svg attribute.
0d92471
to
fc21f21
Compare
8b0995a
to
311c0b9
Compare
5e9b02f
to
f439946
Compare
Before we were checking whether we are clicking inside an element by verifying the bounds. But the easier and more correct approach was to check whether an element is being hovered.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The selection box feature looks very cool. Nice work! We need to make sure modeling tests in Artemis are not affected by the updated selected state. If so, we need to fix them as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent feature, well done! I tested it locally, and everything works as expected, including some edge cases I tried.
The only thing I would add is more tests for the new feature, as the test coverage could be higher. Also, if applicable, the modeling tests in Artemis should be adjusted, as mentioned by @mertyldrr.
File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
---|---|---|---|---|---|
mouse-eventlistener.tsx | 50 | 66.66 | 44.44 | 50 | 90-104,114-155,162-179,187-203,213-239,246-256 |
@AlexanderG2207 @matthiaslehnertum unfortunately, the author is not part of the team anymore. |
Closing in favor of #332 |
Checklist
Motivation and Context
This PR provides the implementation of a selection box using the cursor in order to select multiple elements without the use of the keyboard.
Description
Every time the user clicks OUTSIDE an element, the selection box is created. In order for it to become visible, the user needs to drag the cursor. An element needs to be contained FULLY within the selection box for it to be selected when the selection box is released (i.e. the click/drag action is over). This feature also works when pressing the SHIFT key without deselecting the already selected items.
If the user's cursor goes outside the scope of the canvas while the selection box is active, the selection box will "freeze", but it will continue when the cursor comes back to the canvas. If the user releases the click while the cursor is outside the canvas and they return to the canvas, the selection box will remain active; clicking again will "resume" the selection box and the user can continue to drag the cursor in order to change the already active selection box before releasing it.
Adjustments:
Steps for Testing
Screenshots