Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Dialog the capability to be focusable #616

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

cecton
Copy link

@cecton cecton commented Nov 12, 2021

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
Copy link
Author

cecton commented Nov 19, 2021

@gyscos 😁

@gyscos
Copy link
Owner

gyscos commented Nov 19, 2021

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

In any case, thanks for the work!

@gyscos
Copy link
Owner

gyscos commented Dec 20, 2021

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

/// ```
pub fn print_box<T: Into<Vec2>, S: Into<Vec2>>(
&self,
start: T,
size: S,
invert: bool,
highlight: bool,
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think at this point it may be better to use some parameter-struct (to have named parameters) rather than additional parameters:

use BoxStyle as BS;

printer.print_box(start, size, BS { invert: false, highlight: false });

@cecton
Copy link
Author

cecton commented Dec 22, 2021

Yes I noticed Dialog kinda grew organically...

I will see to move this to panel

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants