Article Preview
Buy Now
FEATURE
No Shortcuts for Shortcuts
Supporting user-defined keyboard shortcuts is tougher than you'd think
Issue: 14.5 (September/October 2016)
Author: Marc Zeedar
Author Bio: Marc taught himself programming in high school when he bought his first computer but had no money for software. He's had fun learning ever since.
Article Description: No description available.
Article Length (in bytes): 45,700
Starting Page Number: 18
Article Number: 14504
Resource File(s):
project14504.zip Updated: 2016-09-01 11:29:37
Related Link(s): None
Excerpt of article text...
Recently an
xDev reader suggested I write an article about how to add the ability to customize keyboard shortcuts in a Xojo application. My first thought was that this seemed too easy and hardly worth a full article. Then I remembered that I had considered adding such a feature to one of my apps, but had never gotten around to doing it. Perhaps I could kill two birds with one stone—write the article and create code I could use myself down the road.As I began to explore this particular problem, however, I discovered that it's not so easy. In fact, it's darn tricky and very worthy of an article!
I'll preface this by pointing out some caveats to my solution. Please understand that this isn't finished and has some serious limitations. (For example: the code is not yet cross-platform and focuses on the Mac, though it should be easy to make a few modifications to support Windows. Supporting
both is more complicated, however.)Think of what I show you as a proof of concept instead of complete code you can pop into your own projects. It should still serve as a good starting point, however, and alert you to some of the issues you'll run into.
What Are Keyboard Shortcuts?
To begin with, it might be good to define what we mean when we say "keyboard shortcut." The most common example are menu commands: most have a shortcut associated with them so you can hit a combination of keys to execute that command without having to mouse to the menu.
...End of Excerpt. Please purchase the magazine to read the full article.