Trouble with Ampersand Character

This forum is for questions / discussions regarding development of addons / tweaks for MediaMonkey.

Moderator: Gurus

wxdude
Posts: 96
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Trouble with Ampersand Character

Post by wxdude » Sat Dec 15, 2012 5:54 pm

Does any one know if the Ampersand character (&) needs to be escaped when used in some circumstances?

For example with the code below, the form caption displays the & character correctly, yet the button caption does not. Seems that the & and a space is replaced with an underscore.

Image

The answer is probably simple but I cannot for the life of me figure out how to get the ampersand to display properly on the button...can anyone provide some guidance?

Thanks.

Code: Select all

Option Explicit

Dim Form, Btn
Sub OnStartup
	Script.RegisterEvent SDB, "OnPlay", "OnPlaybackStart"
End Sub

Sub OnPlaybackStart

	Set Form = SDB.UI.NewForm
	Form.Common.SetRect 100, 100, 500, 400
	Form.Caption = "Title with an & ampersand"
	 
	Set Btn = SDB.UI.NewButton(Form)
	Btn.Caption = "Close & exit"
	Btn.Common.SetRect 10, 10, 100, 20
	 
	Form.ShowModal

End Sub

Lowlander
Posts: 44266
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Trouble with Ampersand Character

Post by Lowlander » Sat Dec 15, 2012 10:30 pm

Lowlander (MediaMonkey user since 2003)

wxdude
Posts: 96
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Re: Trouble with Ampersand Character

Post by wxdude » Sun Dec 16, 2012 1:37 am

Thanks for that Lowlander.

I knew it had to be easy and I tried every other escape sequence I knew of....guess I'm just unsure why it has to be escaped in button text, but not the form text.

Lowlander
Posts: 44266
Joined: Sat Sep 06, 2003 5:53 pm
Location: MediaMonkey 5

Re: Trouble with Ampersand Character

Post by Lowlander » Mon Dec 17, 2012 3:43 pm

In the button a single & is used to indicate the shortcut key to access the button. ie. If you have a button text like Click H&ere the e is used as shortcut key (Alt+E or if that's wrong Ctrl+E).
Lowlander (MediaMonkey user since 2003)

wxdude
Posts: 96
Joined: Fri Mar 12, 2010 4:02 pm
Location: Canada

Re: Trouble with Ampersand Character

Post by wxdude » Tue Dec 18, 2012 6:15 pm

Now it's starting to make sense to me.....thanks again Lowlander.

Post Reply