It is currently Tue Aug 21, 2018 10:31 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Ampersand doesn't appear in option gadget text
PostPosted: Mon Dec 19, 2016 10:10 am 
Offline
User
User

Joined: Mon Nov 03, 2003 5:34 am
Posts: 24
The problem that I'm having is that ampersands don't appear in option gadget text.

Example Code
Code:
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.
viewtopic.php?f=13&t=61540
viewtopic.php?f=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:
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


Top
 Profile  
Reply with quote  
 Post subject: Re: Ampersand doesn't appear in option gadget text
PostPosted: Mon Dec 19, 2016 10:16 am 
Offline
Addict
Addict
User avatar

Joined: Sat Feb 19, 2011 3:47 am
Posts: 2085
Location: Singapore
Axeman wrote:
...Surely there's some way of including an ampersand in OptionGadget text?

Just prefix another ampersand:
Code:
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

_________________
Texas Instruments 99/4A Home Computer: the first home computer with a 16bit processor, crammed into an 8bit architecture. Great hardware - Poor design - Wonderful BASIC engine. And it could talk too!


Top
 Profile  
Reply with quote  
 Post subject: Re: Ampersand doesn't appear in option gadget text
PostPosted: Mon Dec 19, 2016 10:19 am 
Offline
Addict
Addict
User avatar

Joined: Sat Jun 30, 2007 8:04 pm
Posts: 3221
The ampersand will underline up to a single following letter in the denoted string and is meant to provide a hint for accelerators such as alt-key shortcuts. You have to escape it with "&&".

I only know that this is the functionality by-design for Win32. It might behave differently on other platforms.

_________________
Image


Top
 Profile  
Reply with quote  
 Post subject: Re: Ampersand doesn't appear in option gadget text
PostPosted: Mon Dec 19, 2016 10:55 am 
Offline
User
User

Joined: Mon Nov 03, 2003 5:34 am
Posts: 24
Ok, thanks for the info. The double ampersand fix worked for me.

I think this really needs to be added somewhere in the Purebasic docs, though. Possibly in the main 'Gadgets' documentation page.


Top
 Profile  
Reply with quote  
 Post subject: Re: Ampersand doesn't appear in option gadget text
PostPosted: Sat Apr 21, 2018 9:30 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1563
Location: Germany (Saxony, Deutscheinsiedel)
I leave to this for Fred/freak to check + comment, especially to be aware of probably different behaviour on the different supported OS.
(furthermore I wouldn't be sure, where the best place is to add a note in the docs...)

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye