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

Override Mouse Controls while working in Jupyter Notebook #1156

Open
rajatkrpal opened this issue Jan 31, 2025 · 1 comment
Open

Override Mouse Controls while working in Jupyter Notebook #1156

rajatkrpal opened this issue Jan 31, 2025 · 1 comment
Assignees

Comments

@rajatkrpal
Copy link

rajatkrpal commented Jan 31, 2025

I was looking to override the default "clickPick-left" and "hoverPick" feature in the NGLwidget and add customized mouse actions, like "when left mouse is clicked on an atom, it will show a highlight representation"

I am trying this on Jupyter notebook, however, when I do this override using the Javascript code

view = nv.NGLWidget()
view._js("""
this.stage.signals.componentAdded.add((component) => {
    // remove default hover/click pick
    this.stage.mouseControls.remove("hoverPick");
    this.stage.mouseControls.remove("clickPick-left");
});
""")

and then add new components in the widget, it removes the default controls .

However,

in a different cell, if I add new component and try to update the widget and view it

view.update_representation()
view

The override is gone and default mouseControls are observed, like clicking with left mouse, centers the atom, etc.

How do I make sure that NGLwidget can get updated with the addition of new components,
but I can remove the default mouse controls just once and it does not get updated to default the next time, I try to view the NGLwidget?

@hainm
Copy link
Collaborator

hainm commented Feb 3, 2025

The issue is noted and I don't have an answer currently. Cheers.

@hainm hainm self-assigned this Feb 4, 2025
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

No branches or pull requests

2 participants