Menus - extra parameter for shortcut

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
syntax error
User
User
Posts: 93
Joined: Tue Jan 13, 2004 5:11 am
Location: Midlands , UK

Menus - extra parameter for shortcut

Post 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)
Berikco
Administrator
Administrator
Posts: 1326
Joined: Wed Apr 23, 2003 7:57 pm
Location: Belgium
Contact:

Post by Berikco »

Looks like a very good idea to me :)
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

yeah. would save some writing.
Dare2
Moderator
Moderator
Posts: 3321
Joined: Sat Dec 27, 2003 3:55 am
Location: Great Southern Land

Post by Dare2 »

Nice idea. :)

Edit:
Agree with GPI on optional.
Last edited by Dare2 on Mon May 31, 2004 1:23 pm, edited 2 times in total.
GPI
PureBasic Expert
PureBasic Expert
Posts: 1394
Joined: Fri Apr 25, 2003 6:41 pm

Re: Menus - extra parameter for shortcut

Post by GPI »

Good idea, but

Code: Select all

MenuItem(MenuItemID, Text$ [, ShortCut])
OPTIONAL!
Kale
PureBasic Expert
PureBasic Expert
Posts: 3000
Joined: Fri Apr 25, 2003 6:03 pm
Location: Lincoln, UK
Contact:

Post 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
--Kale

Image
fweil
Enthusiast
Enthusiast
Posts: 725
Joined: Thu Apr 22, 2004 5:56 pm
Location: France
Contact:

Post 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
My avatar is a small copy of the 4x1.8m image I created and exposed at 'Le salon international du meuble à Paris' january 2004 in Matt Sindall's 'Shades' designers exhibition. The original laminated print was designed using a 150 dpi printout.
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post 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.
Num3
PureBasic Expert
PureBasic Expert
Posts: 2812
Joined: Fri Apr 25, 2003 4:51 pm
Location: Portugal, Lisbon
Contact:

Post 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!
thefool
Always Here
Always Here
Posts: 5875
Joined: Sat Aug 30, 2003 5:58 pm
Location: Denmark

Post by thefool »

you got a point, num3
Post Reply