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

[Question] How can I detect right-click using plugin callbacks? #3654

Closed
usfbih8u opened this issue Feb 6, 2025 · 4 comments
Closed

[Question] How can I detect right-click using plugin callbacks? #3654

usfbih8u opened this issue Feb 6, 2025 · 4 comments

Comments

@usfbih8u
Copy link
Contributor

usfbih8u commented Feb 6, 2025

micro 2.0.14 (Linux)

Looks like MousePress, MouseMultiCursor, MouseRelease and MouseDrag are related with left-click:

// Mouse bindings from runtime/help/keybindings.md
"MouseWheelUp":     "ScrollUp",
"MouseWheelDown":   "ScrollDown",
"MouseLeft":        "MousePress",
"MouseLeftDrag":    "MouseDrag",
"MouseLeftRelease": "MouseRelease",
"MouseMiddle":      "PastePrimary",
"Ctrl-MouseLeft":   "MouseMultiCursor",

showkey shows no binding for right-click (MouseRight).

@dmaluka
Copy link
Collaborator

dmaluka commented Feb 6, 2025

Yes, MouseRight, MouseRightRelease and MouseRightDrag are not bound to any actions by default, but you can bind them to any actions you like (if that is what you are asking about).

@usfbih8u
Copy link
Contributor Author

usfbih8u commented Feb 8, 2025

But right-click is able to change the focus in the splits. How? I want to detect that for my plugin.

Where is the change of split with right-click in the micro code? So I can investigate more.

Is there any way of detecting it, besides onSetActive()?

@dmaluka
Copy link
Collaborator

dmaluka commented Feb 8, 2025

Ah, yes. Currently any mouse button click (left, right or middle) always activates the split pane it clicks on, even if this button is not bound to any action. This hardcoded logic is in Tab.HandleEvent():

t.SetActive(i)

See also commit 2d95064 (which was a part of PR #2606).

Is there any way of detecting it, besides onSetActive()?

There is also a more low-level way using onAnyEvent, which allows to compare the current active pane with the pane that was active when before the last event. But I think in this case it is no better than onSetActive, since it doesn't allow to detect whether the pane was activated with right-click or any other way.

@usfbih8u
Copy link
Contributor Author

usfbih8u commented Feb 8, 2025

Thank you for your response!

@usfbih8u usfbih8u closed this as completed Feb 8, 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