Skip to main content
Known Participant
July 1, 2009
Question

My menu item's shortcut key doesn't work

  • July 1, 2009
  • 1 reply
  • 5625 views

I add a shortcut key "Ctrl + Alt + C" for my own menu item using the statement

sAIMenu->SetItemCmd(menuItem,
                                'C',kMenuItemCmdControlModifier|
                                kMenuItemCmdOptionModifier);

I can see the string "Ctrl + Alt + C" display on the right side of my own menu item after launch the illustrator .I wish to pop up a dialog after I press the keys,but nothing happens.I think if I should add more codes to make the shortcut key work,may be some notificaiton?

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
July 2, 2009

If it shows up in the Illustrator keyboard shortcut list, that's usually an indicator that you did it correctly. One thing that might be a problem: it looks like you used a capital C not a lower-case C -- is it expecting SHIFT as well? I have a vague recollection about that. If not, I'm not sure, it sure looks like you're doing the right thing.

Known Participant
July 3, 2009

After my study,this problem only occurs on Windows platform,Mac is good.I build two  projects on Windows and Mac using the same sample code(take from illustrator CS4's sample code) and add the same test statements,but the test result is different.On Mac ,the shortcut key can work.

I used many key combinations,such as "Alt+Ctrl+C","Alt+Ctrl+c","Alt+Ctrl+e","Shift+Ctrl+f"...,on Mac ,it can work,but on Windows,it failed.

I found Adobe's SDK is not very exact. The SDK say


kMenuItemCmdShiftModifier  Shift key. 
kMenuItemCmdOptionModifier  Option key in Mac OS, Alt key in Windows. 
kMenuItemCmdControlModifier  Command key in Mac OS, Ctrl key in Windows

After my test,I found on Mac ,the definition is correct,but on Windows,the fact is

kMenuItemCmdShiftModifier = Ctrl+ Shift key. 
kMenuItemCmdOptionModifier = Ctrl+ Alt key  
kMenuItemCmdControlModifier =  Ctrl key

I'm not sure if these deference will affect the plugin's shortcut key on different platform.

A. Patterson
Inspiring
July 3, 2009

Yes, that's because Illustrator was written for Mac originally and ported over. The command constants reflect the original target platform, namely the Mac. If you look at the comments in AIMenu.h (at least in CS3 SDK or later) it tells you what the key is on Windows.

/** Modifier keys for command characters (keyboard shortcuts).
    See \c #AIMenuSuite::SetItemCmd() and \c #AIMenuSuite::GetItemCmd(). */
enum AIMenuItemModifier {
    /** Shift key */
    kMenuItemCmdShiftModifier            = 1,
    /** Option key in Mac OS, Alt key in Windows. */
    kMenuItemCmdOptionModifier            = 2,
    /** Command key in Mac OS,  Ctrl key in Windows. */
    kMenuItemCmdControlModifier            = 4        // the control key on the Mac.
};

These have always proved correct for me in my testing. Are you still having trouble making it work on Windows? I never had any trouble there -- in fact, I did it on Windows first.