You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm currently working on a Rust application using the Cursive TUI library and I'm utilizing the SelectView for a form-like interaction within my application. The default behavior of SelectView (and similar views) is to trigger a submit action or finalize a selection upon pressing the Enter key.
For my specific use case, I'm interested in customizing this behavior to use the Space key as the trigger for the submission action instead of the Enter key. This adjustment would better suit the interaction design of my application, making it more intuitive for my users.
I've gone through the documentation and examples but haven't found a clear way to implement this customization. I'm reaching out to ask if this functionality is currently supported by Cursive and, if so, could you please provide guidance on how to implement this? Alternatively, if this functionality is not supported, I'd like to formally request it as a feature addition to the library.
The ability to customize the key binding for submission actions in SelectView (and potentially other views) would greatly enhance the flexibility of Cursive for developing interactive TUI applications.
Thank you for your time and for the excellent work on the Cursive library. I look forward to your response.
The text was updated successfully, but these errors were encountered:
There are several ways to configure the callback, but here we'll go with the method that gives us the most control: on_pre_event_inner. It runs before the event is given to the wrapped view, and will have direct access to the wrapped view itself, allowing us to return another callback to run on &mut Cursive.
Here we just pretend it was an Enter key. If SelectView::submit was public, you could directly call that instead. I'm not sure why it's not public at the moment - I'll probably make it public soon, so you could do the same more explicitly (without having to fake an Enter key).
You could also override the Enter key, to prevent the SelectView from seeing it:
use cursive::views::{SelectView,OnEventView};let select_view = SelectView::new();use cursive::event::{Event,Key};let wrapped = OnEventView::new(select_view).on_pre_event_inner(' ', |view, _event| {Some(view.on_event(Event::Key(Key::Enter)))}).on_pre_event_inner(Key::Event, |_view, _event| {// Returning `Some` here means the wrapped view does not get to see that event.Some(EventResult::Ignored)});
Hello Cursive Team,
I'm currently working on a Rust application using the Cursive TUI library and I'm utilizing the SelectView for a form-like interaction within my application. The default behavior of SelectView (and similar views) is to trigger a submit action or finalize a selection upon pressing the Enter key.
For my specific use case, I'm interested in customizing this behavior to use the Space key as the trigger for the submission action instead of the Enter key. This adjustment would better suit the interaction design of my application, making it more intuitive for my users.
I've gone through the documentation and examples but haven't found a clear way to implement this customization. I'm reaching out to ask if this functionality is currently supported by Cursive and, if so, could you please provide guidance on how to implement this? Alternatively, if this functionality is not supported, I'd like to formally request it as a feature addition to the library.
The ability to customize the key binding for submission actions in SelectView (and potentially other views) would greatly enhance the flexibility of Cursive for developing interactive TUI applications.
Thank you for your time and for the excellent work on the Cursive library. I look forward to your response.
The text was updated successfully, but these errors were encountered: