Microsoft KB Archive/57778

= How to Make COMMAND+Key Alternatives to MENUs in BASIC =

Article ID: 57778

Article Last Modified on 11/21/2006



This article was previously published under Q57778



SUMMARY
To make COMMAND+key options serve as an alternative to selecting user-defined MENUs with the mouse, you can use the CMDKEY statement (an MBLC Toolbox library routine). The CMDKEY statement also automatically places the special COMMAND-key-character symbol in the menu item (see the code example below). This information applies to Microsoft QuickBASIC Version 1.00 for the Apple Macintosh.



MORE INFORMATION
The CMDKEY Toolbox library statement is described on Page 477 of the &quot;Microsoft QuickBASIC for Apple Macintosh: Language Reference&quot; manual.

Code Example
This example is based on the MenuKeys sample program, located in the Programs Folder in the MS ToolLib Folder on Disk 2 (the BASIC ToolBox Disk) of Microsoft BASIC Compiler Version 1.00 for the Apple Macintosh, and in the same location on the BASIC ToolBox Disk for Microsoft BASIC Interpreter Version 3.00 for the Apple Macintosh. These products are the precursors to QuickBASIC, and the features are similar. To make the program below match MenuKeys and work in these earlier BASIC products, just add the statement LIBRARY &quot;BASIC Toolbox:ToolLib&quot; at the top.

When you run this program, press COMMAND+B to select the Bold menu item, or press COMMAND+I to select the Italic menu item. TEXTMODE 10 FOR n=1 TO 5 MENU n,0,0,&quot;&quot; NEXT n MENU 1,0,1,&quot;File&quot; MENU 1,1,1,&quot;Quit&quot; CmdKey 1,1,&quot;Q&quot; MENU 2,0,1,&quot;Print&quot; MENU 2,1,1,&quot;Bold&quot; MENU 2,2,1,&quot;Italic&quot; CmdKey 2,1,&quot;B&quot;        ' Press COMMAND+B for bold. CmdKey 2,2,&quot;I&quot;        ' Press COMMAND+I for italic. SetItemStyle 2,1,1 SetItemStyle 2,2,2 ON MENU GOSUB event MENU ON delay: GOTO delay END event: MENU men=MENU(0) item=MENU(1) IF men=1 THEN STOP TEXTFACE item PRINT&quot;This is the style you chose&quot; RETURN

Additional query words: BasicCom MQuickB

Keywords: KB57778

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.