Skip to main content
November 16, 2012
Question

Creating Shortcut Keys for Menu Item

  • November 16, 2012
  • 1 reply
  • 2024 views

Hi All,

I have added a Menu Item in File Menu in Adobe Illustrator CS6.

Its working greate.

But I want to create a Short-Cut Key for it (CTRL+J).

I am using  AI CS6 SDK for it.

How will it be possible.

Plsase help me out...

Thanks

Harsh S

This topic has been closed for replies.

1 reply

A. Patterson
Inspiring
November 16, 2012

You have to make sure you give the menuitem a proper name when you create it (2nd parameter I believe). If you've done that, you can assign a default shortcut to it like so:

char commandChar = 't';

short modifier =  kMenuItemCmdShiftModifier; // see AIMenu.h for the AIMenuItemModifier type

sMenu->SetItemCmd(menu_handle, commandChar, modifier);

NOTE: if you pick something that Illustrator's plugins use, you will end up with an entry in the shortcut list, but your shortcut will probably be blank. You might be able to override AI's default shortcuts if you do SetItemCmd() late enough, but I'm not sure about that. Safer to pick things not being used.

November 20, 2012

Hi,

I tried the above solution in the following way:

  •     char commandChar = 'e';
  •    
  •     short modifier =  kMenuItemCmdControlModifier; // see AIMenu.h for the AIMenuItemModifier type
  •     error= sAIMenu->SetItemCmd(fSaveNGCAIMenu, commandChar, modifier);
  •    
  •     throwAwayMenuData.groupName = kSaveMenuGroup;
  •     throwAwayMenuData.itemText = ai::UnicodeString("Save NGC");   
  •     error = sAIMenu->AddMenuItem(message->d.self, "Save NGC", &throwAwayMenuData, 0, &fSaveNGCAIMenu);

Its getting compile successfully and creating the AIP file .

but when I start Illustrator its giving me the following error:

--------------

     Harsh

A. Patterson
Inspiring
November 20, 2012

You have to add the menuitem before you can use it to set its shortcut Try instead:

*     throwAwayMenuData.groupName = kSaveMenuGroup;

*     throwAwayMenuData.itemText = ai::UnicodeString("Save NGC");   

*     error = sAIMenu->AddMenuItem(message->d.self, "Save NGC", &throwAwayMenuData, 0, &fSaveNGCAIMenu);

*

*     char commandChar = 'e';

*

*     short modifier =  kMenuItemCmdControlModifier; // see AIMenu.h for the AIMenuItemModifier type

*     error= sAIMenu->SetItemCmd(fSaveNGCAIMenu, commandChar, modifier);