Shortcut keys for QButtons
Folks,
I recently added a "keyboard shortcut key" concept for QButtons in my app. The idea is that I can define a button, just like I always would:
$objButton = new QButton($this);
$objButton->Text = "Save";
$objButton->AddAction(new QClickEvent(), new QAjaxAction('button_clicked'));And then I can say "add a keyboard shortcut Ctrl+S - whenever the user presses it, behave as if the user pressed the button". I encapsulated it like this:
$objButton->AddShortcut('ctrl', 'S');What this does is establishes a shortcut key, and also changes the Text value of the objButton to make the shortcut more discoverable (it finds the first S in the text of the button, and changes that S to be underlined and have a slightly bigger font - just like all good ol' Windows applications have it).
My code is based upon this library: http://www.openjs.com/scripts/events/keyboard_shortcuts/
There's a jquery port: http://code.google.com/p/js-hotkeys/.
Question: is anyone interested in me making this into a plugin? Or, if there's a lot of interest, I can happily add this to QButtonBase.

I love this idea! I'd like to see it in the base myself ...
It's too bad there's so much extra JS there. If you can get it to only include that .js file when the feature is actually in use, I think this is globally applicable and worth putting in core. :)
Here's what I think I can do: as soon as the user calls AddKeyboardShortcut() on the button, that method will call AddJavascriptFile(). How does that sound, folks?
Sounds great. :) That function already checks for dupes, so I think we're golden.
Was this ever implemented? I'm currently working on a project where it would be very helpful.
hi,
I would also be very interested in seeing this as a plugin or directly in QButtonBase.
thanks,
Tom
Moved my code here: http://trac.qcu.be/projects/qcubed/ticket/727
Does someone have some time to take it to the next level and get it ready for the inclusion into the core?