Example Code
Code: Select all
If OpenWindow(0, 0, 0, 140, 80, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OptionGadget(0, 10, 10, 120, 20, "Option 1 - &Test")
OptionGadget(1, 10, 30, 120, 20, "Option 2 - &Test")
OptionGadget(2, 10, 50, 120, 20, "Option 3 - &Test")
SetGadgetState(1, 1) ; set second option as active one
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
This issue appears to be something to do with a Windows #SS_NOPREFIX flag near as i can tell from the forum posts below. This seems to be a behavior that was changed for some gadgets (TextGadgets) a few years ago, but doesn't seem to have been changed for OptionGadgets. I can't see the point of having this behavior for OptionGadgets as it doesn't achieve anything useful, so I assume this is some kind of bug or oversight.
A couple of threads that seem to be related.
http://www.purebasic.fr/english/viewtop ... 13&t=61540
http://www.purebasic.fr/english/viewtop ... 13&t=58677
I can't seem to disable this nonsense either. Surely there's some way of including an ampersand in OptionGadget text?
Code: Select all
If OpenWindow(0, 0, 0, 140, 80, "OptionGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
OptionGadget(0, 10, 10, 120, 20, "Option 1 - &Test")
OptionGadget(1, 10, 30, 120, 20, "Option 2 - &Test")
OptionGadget(2, 10, 50, 120, 20, "Option 3 - &Test")
SetGadgetState(1, 1) ; set second option as active one
SetWindowLongPtr_( GadgetID( 0 ), #GWL_STYLE, GetWindowLongPtr_( GadgetID( 0 ), #GWL_STYLE ) | #SS_NOPREFIX )
SetGadgetText( 0, "Option X - &Test" )
Repeat : Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf