Using the ampersand "&" in TextGadgets

Everything else that doesn't fall into one of the other PB categories.
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Using the ampersand "&" in TextGadgets

Post by Sparkie »

Can anyone explain why the ampersand "&" doesn't display in the first 2 TextGadgets of this code...

Code: Select all

If OpenWindow(0, 0, 0, 300, 150,  #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_TitleBar , "test")
  If CreateGadgetList(WindowID())
    TextGadget(1, 20, 40, 160, 20, "Dumb & Dumber")
    TextGadget(2, 20, 70, 160, 20, "Dumb " + Chr(38) + " Dumber")
    TextGadget(3, 20, 100, 160, 20, "Dumb &" + Chr(38) + " Dumber")
    For g = 1 To 3
      Debug GetGadgetText(g)
    Next
  EndIf
EndIf

Quit = #False

Repeat
  event = WaitWindowEvent()
  
  Select event
    
    Case #PB_EventCloseWindow
      Quit = #True
      
  EndSelect
Until Quit
End

The TextGadgets display as:

#1 displays as Dumb_Dumber
#2 displays as Dumb_Dumber
#3 displays as Dumb & Dumber

and the Debug window displays as expected. :?
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
User avatar
Paul
PureBasic Expert
PureBasic Expert
Posts: 1285
Joined: Fri Apr 25, 2003 4:34 pm
Location: Canada
Contact:

Post by Paul »

Because & is a special Windows character that tells it the next character after the & should be underlined.

If you want "Dumb & Dumber" you need "Dumb && Dumber"

In your example you see "Dumb_Dumber" because the next character after your & is a space, so it is underlining the space.
Image Image
Sparkie
PureBatMan Forever
PureBatMan Forever
Posts: 2307
Joined: Tue Feb 10, 2004 3:07 am
Location: Ohio, USA

Post by Sparkie »

Thank you for clearing that up Paul :)
What goes around comes around.

PB 5.21 LTS (x86) - Windows 8.1
Post Reply