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

Delete Object Keyboard Shortcut #388

Merged
merged 8 commits into from
Jul 30, 2024
Merged

Conversation

arjxn-py
Copy link
Member

Should fix #46
Adds a Ctrl+X keybinding to delete object.

Copy link
Contributor

Binder 👈 Launch a Binder on branch arjxn-py/JupyterCAD/delete-model

@martinRenou martinRenou added the enhancement New feature or request label Jul 29, 2024
Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Neat! Thanks.

A small issue I spotted, when selecting an edge the title of the dialog is kind-of wrong, because we cannot just delete an edge. So we should probably find the parent object of the edge and delete that parent instead.

Screencast.from.2024-07-29.09-28-47.mp4

[
{
"command": "jupytercad:removeObject",
"keys": ["Accel X"],
Copy link
Member

Choose a reason for hiding this comment

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

I feel like "Accel X" should be the keybinding for "cut", though we don't have any copy/paste logic available so I'm fine keeping this keybinding for now if you like 👍🏽

Though should we also add "Delete" there too in the list?

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks, that makes much sense as xref:QuantStack/jupytergis#68 also uses the [Delete] key for the same.

Also it sounds nice to have a feature request open for cut/copy/paste logic. I can open one if it's fine.

Copy link
Member

Choose a reason for hiding this comment

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

I can open one if it's fine

Sounds good!

{
"command": "jupytercad:removeObject",
"keys": ["Accel X"],
"selector": ".jp-jupytercad-panel"
Copy link
Member

Choose a reason for hiding this comment

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

This results in the key binding to not be triggered if it's the left panel (object list) that has focus.

I wonder if we should add the keybinding to the #main application instead. Though I tested locally and that does not seem to work, I suppose it's because the command depends on the WidgetTracker<JupyterCadWidget> tracker, and that one only tracks the 3D view if I'm correct.

Let's not consider this a blocker for merging the PR, but let's keep track of this in an issue after merging.

Copy link
Member Author

Choose a reason for hiding this comment

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

I see, i can try adding the valid className for left panel too and see if the union of jupytercad-panel & leftpanel works.

Copy link
Member Author

@arjxn-py arjxn-py Jul 29, 2024

Choose a reason for hiding this comment

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

I thought it was easy.
But it was not as simple as I thought 😅, there seem to be a complexity with the Document Object Model that all the components are not naturally focusable on click, which was not letting me to have a specific component as a selector.
But at last it was done by defining tabIndex={0} & one can now delete object with key binding while being on ObjectTree too.

Copy link
Member

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Member

@martinRenou martinRenou left a comment

Choose a reason for hiding this comment

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

Thanks!

@martinRenou martinRenou merged commit fb39912 into jupytercad:main Jul 30, 2024
9 checks passed
@arjxn-py
Copy link
Member Author

A small issue I spotted, when selecting an edge the title of the dialog is kind-of wrong, because we cannot just delete an edge.

Thanks for merging this @martinRenou, And sorry for the delay I was still looking into the edge issue. I'll open a PR upstream as soon as i manage to fix it and if not I'll definitely open an issue to keep track of it.

@trungleduc
Copy link
Member

Great! Thanks for working on it

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

Successfully merging this pull request may close these issues.

Delete key binding
3 participants