cursive
cursive copied to clipboard
Add Dialog the capability to be focusable
Hello!
I found this feature missing: you can set a dialog to be "focusable". This means you can focus on the dialog itself, it will take the title primary color and it can take a callback function.
The callback function is optional: if you don't use the callback, pressing enter will give the focus to the content of the dialog.
If you press Tab or Shift+Tab it will start focusing the buttons instead.
This is similar to the "interactive" feature of the component Card of Blueprint.js
I will use it to make a new CLI for my library gptman.
Show case:
cargo run --example focusable_dialog
@gyscos :grin:
Hi! Yes yes, will take a look soon. A bit busy these days :(
In any case, thanks for the work!
I'm wondering if it could be maybe a better fit for panels?
Dialog
is a bit of a mix of many things (in big part because it was one of the first ever views to be implemented, so it has quite some baggage...), and is meant to be a convenient "top-level" view in a layer, rather than a real component to embed in a layout. And judging from the example (and your own nice gptman
), this new feature is best suited for components embedded in a larger layout.
The more recent Panel
is trying to be the more minimal and re-usable counterpart. I think making panels focusable could be a great idea!
Do you think it would work for your use-case? In particular, panels don't have the same convenient integrated row of buttons (you would have to add the buttons in a LinearLayout or something).
Yes I noticed Dialog kinda grew organically...
I will see to move this to panel