Skip to content

Pass mouse info to {on,pre}MouseXXX callbacks - #3779

Merged
dmaluka merged 3 commits into
micro-editor:masterfrom
dmaluka:on-pre-mouse-pass-te
Jun 29, 2025
Merged

Pass mouse info to {on,pre}MouseXXX callbacks#3779
dmaluka merged 3 commits into
micro-editor:masterfrom
dmaluka:on-pre-mouse-pass-te

Conversation

@dmaluka

@dmaluka dmaluka commented Jun 21, 2025

Copy link
Copy Markdown
Collaborator

Pass *tcell.EventMouse to action callbacks for "mouse actions", i.e. to onMousePress, preMouseDrag and so on, similarly to how we pass it to lua functions bound to mouse events.

dmaluka added 3 commits June 21, 2025 03:04
So that we can pass extra arguments to bufpane callbacks easily, by
passing them directly to PluginCB().
Pass *tcell.EventMouse to action callbacks for "mouse actions", i.e. to
onMousePress, preMouseDrag and so on, similarly to how we pass it to lua
functions bound to mouse events.
Now that we can pass extra args directly to PluginCB(), we can remove
PluginCBRune() for simplicity.
@cutelisp

Copy link
Copy Markdown
Contributor

Thanks for this! I tested and it seems to be working fine.

success = a(h, te)
}
success = success && h.PluginCB("on"+name)
success = success && h.PluginCB("on"+name, te)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

We add this now also for BufKeyAction too, right?
Furthermore...is this optional argument really backward compatible? 🤔

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

We add this now also for BufKeyAction too, right?

Yes, but it is nil in that case.

Furthermore...is this optional argument really backward compatible? 🤔

Non-intuitively yes. You can try it. A lua function is free to receive less arguments than we pass to it, or more arguments than we pass to it.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ah, ok. Then it is legit. 👍

@dmaluka
dmaluka merged commit 41b912b into micro-editor:master Jun 29, 2025
@cutelisp

Copy link
Copy Markdown
Contributor

Documentation lacks this new feature.

@dmaluka

dmaluka commented Jul 5, 2025

Copy link
Copy Markdown
Collaborator Author

Documentation lacks this new feature.

Yeah. Uploaded #3799

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.

3 participants