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

KEY_TAB to switch between widgets and provide focus #46

Closed
pkazmier opened this issue Apr 8, 2020 · 3 comments
Closed

KEY_TAB to switch between widgets and provide focus #46

pkazmier opened this issue Apr 8, 2020 · 3 comments
Labels
Core Add for issues having to do with core functions Feature Request Add for a new feature request
Milestone

Comments

@pkazmier
Copy link

pkazmier commented Apr 8, 2020

For the app I built, I found the Overview and Focus modes a bit unfriendly to use. I have three widgets on my screen as follows.

+--------------------------------------------------------------------------+
|                                     |                                    |
|                                     |                                    |
|                                     |                                    |
|-------------------------------------|                                    |
|                                     |                                    |
|                                     |                                    |
|                                     |                                    |
+--------------------------------------------------------------------------+

Arrow navigation felt a bit wonky in overview mode (as previously reported by a different user), so I wanted to simply make consecutive TAB presses cycle through the three widgets and placing it in focus mode automatically.

So, here is what I did in case anyone else wants to do the same:

        focus = itertools.cycle(root.widgets.values())

        def select_next_widget():
            root.move_focus(next(focus))

        root.add_key_command(py_cui.keys.KEY_TAB, select_next_widget)
        menu1.add_key_command(py_cui.keys.KEY_TAB, select_next_widget)
        menu2.add_key_command(py_cui.keys.KEY_TAB, select_next_widget)
        menu3.add_key_command(py_cui.keys.KEY_TAB, select_next_widget)
@pkazmier pkazmier added the Feature Request Add for a new feature request label Apr 8, 2020
@jwlodek
Copy link
Owner

jwlodek commented Apr 8, 2020

So the problem with this is that for the textbox/textblock widgets, when in focus mode the tab key is used to write a tab. I could make it so that it moves between widgets in overview mode pretty easily, but I'm not sure how to handle those cases when in focus mode.

@jwlodek jwlodek added the Core Add for issues having to do with core functions label Apr 8, 2020
@jwlodek jwlodek added this to the v0.1.1 milestone Apr 12, 2020
@jwlodek jwlodek modified the milestones: v0.1.1, v0.1.2 May 24, 2020
@jwlodek
Copy link
Owner

jwlodek commented May 24, 2020

I've thought about this, and I think the way we can do it is to allow the user to specify a key to cycle through the different widgets. Then in the case that no text entry widgets are used, and the Tab key would be best, they can just run the function with the tab key.

@pkazmier
Copy link
Author

Sounds reasonable. Maybe we could offer some means of disabling the TAB key in text widgets as well, so users can opt out if they don’t expect users to use the key.

My use case does not have any inputs. Here is a link to my project that uses your library in one of its user-definable commands as well as a screenshot of it.

https://github.com/fmr-llc/awsrun/blob/master/README.md#last-command

It is using version 0.3 for now as it works after my changes for tabbing, page up/down, etc .. I know you’ve been adding these features and once it stabilizes I’ll go back and update it.

Thanks for making this port. I needed something fast a month ago and I am glad to have found your project.

@jwlodek jwlodek mentioned this issue Jun 15, 2020
3 tasks
@jwlodek jwlodek closed this as completed Sep 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Core Add for issues having to do with core functions Feature Request Add for a new feature request
Projects
None yet
Development

No branches or pull requests

2 participants