BBC BASIC for Windows
Programming >> User Interface >> Why the Ampersand ?
http://bb4w.conforums.com/index.cgi?board=ui&action=display&num=1395045731

Why the Ampersand ?
Post by kingsmiller on Mar 17th, 2014, 08:42am


Below is a snippet from a BB4W Example program -

SYS "CreatePopupMenu" TO hsub%
SYS "AppendMenu", hsub%, 0, 0, "&Black"
SYS "AppendMenu", hsub%, 0, 15, "&White"
:
SYS "CreatePopupMenu" TO hpop1%
SYS "AppendMenu", hpop1%, 0, 1, "&Red"
SYS "AppendMenu", hpop1%, 0, 2, "&Green"
SYS "AppendMenu", hpop1%, 0, 4, "&Blue"
:

Why the Ampersand just before the colour name.

I am guessing it should have some visual effect but on my screen I cannot see any difference with or without the ampersand.

I have even seen E&xit (ampersand after the letter E) used, again I do not understand what it should do.

I would guess somewhere in the manual it does explain the reason - but so far I have not come across it.

Could someone throw some light on this subject as I may have forgotten its purpose.

Many Thanks

Re: Why the Ampersand ?
Post by rtr on Mar 17th, 2014, 10:09am

on Mar 17th, 2014, 08:42am, kingsmiller wrote:
I would guess somewhere in the manual it does explain the reason - but so far I have not come across it.

The manual's Search feature finds it. Open the Help viewer (e.g. press F1), click on the Search tab and in the 'Type in the keyword to find' box enter ampersand then click List topics.

The first hit in the results box is 'Adding a menu bar'; double-click on that and it will take you to the relevant section of the manual. There it says this: 'In each case one letter of the name is preceded by an ampersand (&): this determines the keyboard shortcut letter associated with the menu item'.

Quote:
I am guessing it should have some visual effect but on my screen I cannot see any difference with or without the ampersand.

Press the Alt key and all will be revealed! In Windows everything you can do with the mouse should have a keyboard equivalent. In the case of menu selections, that equivalent is to hold down the Alt key and press the key corresponding to the underlined character. Buttons in dialogue boxes have exactly the same feature, and the character is identified in the same way (a preceding ampersand).

Richard.
Re: Why the Ampersand ?
Post by kingsmiller on Mar 17th, 2014, 10:32am


Many Thanks for your reply.

For are quite right - I have searched the manual as suggested and its all explained quite clearly there.

Regards ..