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

feature request: hotkeys for buttons in buttonbox #16

Closed
horstjens opened this issue Dec 2, 2014 · 8 comments
Closed

feature request: hotkeys for buttons in buttonbox #16

horstjens opened this issue Dec 2, 2014 · 8 comments
Assignees
Milestone

Comments

@horstjens
Copy link
Collaborator

so that a press of a key is like the button was cklicked with the mouse.

i suggest using the first Uppercase Char in a button string as hotkey

@robertlugg
Copy link
Owner

Ah, I originally misunderstood. I thought you meant "first character", but now I see, so perhaps a button would have the text "eXit" and then 'X' is the hotkey. Is that correct?

Are there cases where the user wants a different keystroke, so maybe for buttons left, right, up, down, they want a, d, w, s ? How about set priority:
search for &c within the text where 'c' is any single character. If found use it.
if not found, search first first uppercase char
if not found, no hotkey.

Also, if we use '&', then I suggest & should be used to insert an & without assigning a hotkey.

@robertlugg robertlugg added this to the 0.97 Release milestone Dec 3, 2014
@horstjens
Copy link
Collaborator Author

there is the (rare) case that you want the hotkey not to be visible on the button itself (think of translation or many buttons with nearly identical names). Other example would be to have a button with the string "left" but hotkey should be "cursor left key". would be cool to give ascii code or some other code as hotkey parameter (optional)

@robertlugg robertlugg self-assigned this Dec 11, 2014
@robertlugg
Copy link
Owner

I just checked in a change that allows key bindings. One thing to check is if the return is proper. For instance, if a button is named '&Yes', it returns '&Yes' and not 'Yes'.

For a literal &, use a double like: &&

Also modified things such that cancel (Escape, the big red X) will always close a dialog and return None.

Limitation: Can't bind control keys such as arrows Enter, etc to a button.

@robertlugg robertlugg assigned horstjens and unassigned robertlugg Dec 15, 2014
@robertlugg
Copy link
Owner

Horst, I didn't address your request to handle control keys. there also is no way to hide the character. If you have ideas for syntax, I'd appreciate it.

@horstjens
Copy link
Collaborator Author

would it be possible to take the first characther in square brackets as hotkey ? ( like "press this [B]utton" --> B ) as this is how i normally indicate the button to be pressed in a visible text string.

@robertlugg
Copy link
Owner

It should be easy to switch it over. I'll give it a try.

@robertlugg
Copy link
Owner

I updated the code and committed it. Now, you can say [B]utton which will display the B also, or say [[B]]utton, which will hide the B. Or, you can assign a keysym like [] which will bind F1 to that button. One big question: When we return the button pressed, do we include the [, ], etc or not?

@horstjens
Copy link
Collaborator Author

as far as i understand easygui always returns the full text string of the clicked (hotkeyed) button. I vote for including all the square brackets, as it make sense that you get returned the same string that you wrote as parameter.

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

2 participants