Page 1 of 1

Menus - extra parameter for shortcut

Posted: Mon May 31, 2004 9:28 am
by syntax error
How about ...


MenuItem(MenuItemID, Text$, ShortCut)


Would save lots of extra typing:

BEFORE:

Code: Select all

MenuItem(#MENU_new, "New")
MenuItem(#MENU_open,"Open File")
MenuItem(#MENU_Save,"Save File")
MenuItem(#MENU_quit, "Quit")

AddKeyboardShortcut(#Win,#PB_SHORTCUT_N,#MENU_new)
AddKeyboardShortcut(#Win,#PB_SHORTCUT_O,#MENU_open)
AddKeyboardShortcut(#Win,#PB_SHORTCUT_S,#MENU_save)
AddKeyboardShortcut(#Win,#PB_SHORTCUT_Q,#MENU_quit)
AFTER:

Code: Select all

MenuItem(#MENU_new, "New" , #PB_SHORTCUT_N)
MenuItem(#MENU_open,"Open File" , #PB_SHORTCUT_O)
MenuItem(#MENU_Save,"Save File" , #PB_SHORTCUT_S)
MenuItem(#MENU_quit, "Quit" , #PB_SHORTCUT_Q)

Posted: Mon May 31, 2004 10:25 am
by Berikco
Looks like a very good idea to me :)

Posted: Mon May 31, 2004 11:18 am
by thefool
yeah. would save some writing.

Posted: Mon May 31, 2004 12:23 pm
by Dare2
Nice idea. :)

Edit:
Agree with GPI on optional.

Re: Menus - extra parameter for shortcut

Posted: Mon May 31, 2004 12:33 pm
by GPI
Good idea, but

Code: Select all

MenuItem(MenuItemID, Text$ [, ShortCut])
OPTIONAL!

Posted: Mon May 31, 2004 12:47 pm
by Kale
I would go one further:

Code: Select all

MenuItem(MenuItemID, Text$ [, Accelerator$, ShortCut])
Before:

Code: Select all

MenuItem(#MENU_new, "New"  + Chr(9) + "Ctrl+N") 
AddKeyboardShortcut(#Win, #PB_Shortcut_Control | #PB_Shortcut_N,#MENU_new)
After:

Code: Select all

MenuItem(#MENU_new, "New", "Ctrl+N", #PB_Shortcut_Control | #PB_Shortcut_S)
or to be extremly clever have the accelerator text automatically added depending on the shortcut value passed. :D

Posted: Mon May 31, 2004 1:08 pm
by fweil
Kale,

You just make me dreaming of a full clever command. But you point out why such implementation will maybe be difficult !

Anyway, right now, I use to write a procdure to add optional parameters when creating large menus, to save code writing in the main program.

Meaning, this will save even more to have extended menu commands !

Rgrds

Posted: Mon May 31, 2004 1:54 pm
by thefool
@gpi -> i also thought that it should be optional but i was to lazy to write it. (this means that i agree).

@kale -> i agree.

Posted: Mon May 31, 2004 5:42 pm
by Num3
Has where on this subject i propose this little change:

OpenSubMenu(Text$)

to

OpenSubMenu(MenuItemID, Text$)

so we can use DisableMenuItem(MenuItem, State) on SubMenu's!!!

It's a sod to have all items in a submenu disabled, but not the submenu itself!

Posted: Mon May 31, 2004 5:45 pm
by thefool
you got a point, num3