cursive icon indicating copy to clipboard operation
cursive copied to clipboard

Add Dialog the capability to be focusable

Open cecton opened this issue 2 years ago • 4 comments

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.

image

Show case:

cargo run --example focusable_dialog

cecton avatar Nov 12 '21 16:11 cecton

@gyscos :grin:

cecton avatar Nov 19 '21 16:11 cecton

Hi! Yes yes, will take a look soon. A bit busy these days :(

In any case, thanks for the work!

gyscos avatar Nov 19 '21 16:11 gyscos

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).

gyscos avatar Dec 20 '21 14:12 gyscos

Yes I noticed Dialog kinda grew organically...

I will see to move this to panel

cecton avatar Dec 22 '21 13:12 cecton