Conversation
|
Ok, at least it wouldn't break compatibility with existing plugins (I thought it would, but I've just checked that it doesn't)... I'm wondering what is the use case, and how exactly you are gonna use this |
|
I wan't to be able to know the cords of the cursor while dragging. Afais, those values aren't exposed to lua side. I think it's more convenient to expose the event to |
You are assuming that the event is
We could expose them. |
|
Yes, the identification of all of the different event types could be quite hard in this case. With this PR you will have the access to all and everything, but need to take care to access the right type/memory. |
Yes, I've tried it and it works (not heavily tested tho). Maybe I should've sent a better snippet. Maybe not the most neat logic, but this was my approach. |
Right, I think this would be a great addition anyway |
|
I don't think exposing As a plugin author I would rather have new "event callbacks" 1 with more specific arguments and stronger backwards compatibility guarantees, eg. something along the lines of Footnotes
|
Remove approval due to type non-safety within the Lua callbacks.
This would only work in case we expose a further API to check the types we give as callback arg.
I'd prefer something like |
Since the use case by now is just for mouse events maybe we should go this way. We could create |
|
Changed the PR towards this suggestion #3774 (comment) |
| luar.New(ulua.L, e.Buttons()), | ||
| luar.New(ulua.L, e.Modifiers()), |
There was a problem hiding this comment.
I don't think that it is a good idea to export values/definitions from tcell's interface.
Shouldn't we wrap it?
There was a problem hiding this comment.
What do you mean by wrap it, could you give an example?
There was a problem hiding this comment.
By exporting the content of e.Buttons() and e.Modifiers() we implicit export a dependency to the interface of tcell.
If this is OK, then we can go that way, but I've some doubts right now.
The plugins should only have a dependency to micro, but not its dependencies. To solve this we would need to define our own MouseEvent, which we already have (with tcell dependencies too)...
So a new struct could fit the needs and it should include the coordinates, buttons and modifiers. On the other hand this means, that we duplicate this kind of event.
@dmaluka:
What is your opinion about it?
There was a problem hiding this comment.
Actually we already export *tcell.EventMouse to lua in some cases, namely, we pass it to lua functions bound to mouse events (MouseLeft, MouseRight, MouseRightDrag etc), since #2605. Yeah, I'm guilty of that. (Also I'm guilty of not documenting that.)
So, we may debate whether or not it is/was a good idea to directly expose tcell stuff to lua... But since we are already doing that anyway, I think, at least, that simply passing the entire *tcell.EventMouse is in all respects better than passing its components as individual arguments.
...But first of all, I'm not sure we want this new callback in the first place. It seems what we actually want is to pass the mouse info (for example, again, just pass *tcell.EventMouse) to the already existing callbacks of "mouse actions", i.e. to onMousePress, onMouseDrag, onMouseRelease, onMouseMultiCursor, preMousePress, preMouseDrag, preMouseRelease, preMouseMultiCursor.
And that seems easy to implement: #3779
There was a problem hiding this comment.
But since we are already doing that anyway, I think, at least, that simply passing the entire
*tcell.EventMouseis in all respects better than passing its components as individual arguments.
Agree.
There was a problem hiding this comment.
#3779 merged, can we close this PR as unneeded?
There was a problem hiding this comment.
#3779 merged, can we close this PR as unneeded?
Absolutely, thanks for your PR.
This will enhance
onAnyEvent, allowing it to capture event data that's otherwise inaccessible.