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

Focusable widgets #209

Open
cjbassi opened this issue Jan 24, 2019 · 2 comments
Open

Focusable widgets #209

cjbassi opened this issue Jan 24, 2019 · 2 comments

Comments

@cjbassi
Copy link
Contributor

cjbassi commented Jan 24, 2019

Allow one widget to have focus, which grabs control of all keybinds. Also have a global key handler if the widget doesn't use a certain key. Would be good for being able to scroll different widgets.

Some ideas:

  • maybe have a callback per widget for when the widget gains focus
    • would allow for the widget to update its appearance
@pdevine
Copy link

pdevine commented Feb 11, 2020

In PR #257 I just added a variable you can check to see if the widget is currently "Active", although I think maybe it would make sense to call it "InFocus". You can cycle through all of the widgets you care about in the event handler and check if each one is currently focused. I also added a way of setting the "ActiveStyle" (maybe InFocusStyle?) so that you can visually tell which widget is currently in focus.

The nice part about doing it this way is that it doesn't add anything unwieldy to the current code base and shouldn't break any legacy code. There's also not much you need to do to make it work.

The down side to this approach is that you could potentially have multiple widgets in focus simultaneously as there's nothing preventing that case. You'll have to manage the focus yourself in your own code, but I think that's a reasonable tradeoff.

@ayntee
Copy link

ayntee commented Jun 11, 2021

Bump

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

No branches or pull requests

3 participants