I add a shortcut key ''Ctrl + Alt + C'' for my own menu item using the statement
sAIMenu-%26gt;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?
My menu item's shortcut key doesn't workIf 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.
My menu item's shortcut key doesn't workAfter 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.
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.
Yes,I still having trouble making it work on Windows.I attaches my demo project file''ADMNonModalDialogPlugin.cpp''.If you have interest, you can replace the file with the same name in ''..\Adobe Illustrator CS4 SDK\samplecode\ADMNonModalDialog\Source'', and compile on Mac and Windows.
You can see on Mac ,it?works well, but on Windows, it failed.
I add my test code in line 199-203.
Other issue:
In SDK,it says on Windows:
kMenuItemCmdShiftModifier?= Shift key.?
kMenuItemCmdOptionModifier?= Alt key.?
kMenuItemCmdControlModifier?=?Ctrl key
but after my test,on Windows, the meaning of the macros should be
kMenuItemCmdShiftModifier = Ctrl+ Shift key.?
kMenuItemCmdOptionModifier = Ctrl+ Alt key
kMenuItemCmdControlModifier =?Ctrl key
It is strange.
Yes,I still having trouble making it work on Windows. I attaches my file .If you have interest,you can replace the file with the same name in ''..\Adobe Illustrator CS4 SDK\samplecode\ADMNonModalDialog\Source'',and compile the sample then run on Windows and Mac.You can see the menu item at menu''Windows''-%26gt;''SDK''.You will find that on Mac,the short cut key can work well,but on Windows ,it can not.
I added my test code in line 199-203.
Other issue:
In SDK,it says on WIndows:
kMenuItemCmdShiftModifier?= Shift key.?
kMenuItemCmdOptionModifier?=?Alt key .?
kMenuItemCmdControlModifier?= Ctrl key .
Afer my test,I found on Windows:
kMenuItemCmdShiftModifier = Ctrl+ Shift key.?
kMenuItemCmdOptionModifier = Ctrl+ Alt key.
kMenuItemCmdControlModifier =?Ctrl key .
It is very strange,I don't know if the same thing will happen on your computer.
Yes,I still having trouble making it work on Windows. I attaches my file .If you have interest,you can replace the file with the same name in ''..\Adobe Illustrator CS4 SDK\samplecode\ADMNonModalDialog\Source'',and compile the sample then run on Windows and Mac.You can see the menu item at menu''Windows''-%26gt;''SDK''.You will find that on Mac,the short cut key can work well,but on Windows ,it can not.
I added my test code in line 199-203.
Other issue:
In SDK,it says on WIndows:
kMenuItemCmdShiftModifier?= Shift key.?
kMenuItemCmdOptionModifier?=?Alt key .?
kMenuItemCmdControlModifier?= Ctrl key .
Afer my test,I found on Windows:
kMenuItemCmdShiftModifier = Ctrl+ Shift key.?
kMenuItemCmdOptionModifier = Ctrl+ Alt key.
kMenuItemCmdControlModifier =?Ctrl key .
It is very strange,I don't know if the same thing will happen on your computer.
Did you upload the right file? I can't find SetItemCmd() anywwhere in it -- I think you usually add the menu shortcuts elsewhere, all I can see in the ZIP you uploaded isADMNonModalDialog.cpp. Is that what you meant to put up?
I uploaded the wrong file ,now upload the right one ,you can find SetItemCmd() in line 201.Just rename ADMMonModalDialogPlugin.txt to ADMMonModalDialogPlugin.cpp.
Hmmm. I don't see anything wrong with the code, but I haven't tested it yet (that's next). One quick question: CTRL+ALT+C is already in use by a CS4 function to do with Envelopes. In my experience, whenever I tried to use a shortcut used by default by an AI plugin, they won not me. Have you tried a different combination, to see if it has better luck? I usually just load up the Keyboard Shortcut dialog and punch in combinations for some random menuitem until it doesn't complain that I've stolen a shortcut.
I'll try the sample project in a bit, maybe I'll see something else.
Thanks,I load up the Keyboard Shortcut dialog and find ''AltShiftCtrl+6''
is not used.I tried it,but the result is the same.I wish you have good
luck!
Best Regards
Jason Yang
No comments:
Post a Comment