-
|
I have a Cursive instance and am processing keyboard/mouse events in cursive.set_on_pre_event_inner(EventTrigger::any(), move |e| {
// Can't do this since I cannot move "cursive" into closure...
cursive.call_on_name(...);
});How do I get a reference to the Cursive root instance inside my event handler? |
Beta Was this translation helpful? Give feedback.
Answered by
gyscos
Jun 17, 2025
Replies: 1 comment 2 replies
-
|
The superficially similar method |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
set_on_pre_event_inneris the low-level method thatset_on_pre_eventcalls internally. The callback works in two steps:&mut Cursive. You need to decide here if the event should be consumed. In doubt, consume the event.EventResult, which itself can contain a callback usingEventResult::with_cb. That callback will have access to&mut Cursive, and you canmovethe event in there.If you can decide to consume or ignore the event without access to
&mut Cursive(and just need access to it in case you consume the event), then you're good - it's the "easy" case.