TextGadget & spaces

Just starting out? Need help? Post your questions and find answers here.
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

TextGadget & spaces

Post by Psychophanta »

With previous versions of PB (5.xx) it works as expected but now is this correct the behaviour, or is it a bug?:

Code: Select all

OpenWindow(0,0,0,400,300,"Inc",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TrackBarGadget(10,310,0,40,260,0,2E2,#PB_TrackBar_Vertical|#PB_TrackBar_Ticks)
TextGadget(11,240,280,120,20,"purepure:zbasicbasic")
SetGadgetState(10,lat*2E2/180+1E2)
Repeat
  evento.i=WaitWindowEvent(20)
  If evento=#PB_Event_Gadget
    Select EventGadget()
    Case 10
      If GetGadgetState(10)<50:SetGadgetText(11,"purepure: z basicbasic"); with space, then no correct; text is truncated
      ElseIf GetGadgetState(10)<100:SetGadgetText(11,"purepure: basicbasic"); with space, then no correct; text is truncated
      Else:SetGadgetText(11,"purepure:zbasicbasic"); <- correct
      EndIf
    EndSelect
  EndIf
Until evento=#PB_Event_CloseWindow
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: TextGadget & spaces

Post by Caronte3D »

I don't see any truncate text (Win10) :?
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: TextGadget & spaces

Post by Psychophanta »

Really? :shock:
Here win8.1 x64 with PB6.20B4(x86)
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: TextGadget & spaces

Post by Caronte3D »

Maybe the Zoom of your Windows?
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: TextGadget & spaces

Post by AZJIO »

Use #SS_LEFTNOWORDWRAP so that the text does not wrap to a new line.

Code: Select all

TextGadget(11,240,280,120,20,"purepure:zbasicbasic", #SS_LEFTNOWORDWRAP)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: TextGadget & spaces

Post by Psychophanta »

@AZJIO
It works :idea:
But it is not documented :?
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
User avatar
Caronte3D
Addict
Addict
Posts: 1371
Joined: Fri Jan 22, 2016 5:33 pm
Location: Some Universe

Re: TextGadget & spaces

Post by Caronte3D »

Psychophanta wrote: Wed Feb 12, 2025 8:13 am But it is not documented :?
It's a Windows only flag (all #SS_...)
User avatar
Psychophanta
Always Here
Always Here
Posts: 5153
Joined: Wed Jun 11, 2003 9:33 pm
Location: Anare
Contact:

Re: TextGadget & spaces

Post by Psychophanta »

Since 'space' is a character like any other, this post should be moved to bug reports.
http://www.zeitgeistmovie.com

while (world==business) world+=mafia;
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: TextGadget & spaces

Post by AZJIO »

Psychophanta wrote: Wed Feb 12, 2025 7:28 pm Since 'space' is a character like any other, this post should be moved to bug reports.
It's not a mistake. This is Windows behavior for strings that don't fit in the gadget. The word is moved to a new line, not cut off. If you make a gadget two lines high, you will see how the word will be in the second line.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: TextGadget & spaces

Post by Piero »

Use 200?

Code: Select all

TextGadget(11,240,280,200,20,"purepure:zbasicbasic")
PS: with my mac font a good value would be 160

Edit: font has nothing to do with it; it's just 400-240 (instead of 400-280 ;))
Last edited by Piero on Fri Feb 14, 2025 1:59 am, edited 1 time in total.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: TextGadget & spaces

Post by Piero »

160 should be good for win too… this is TextGadget(11,240,280,160,20,"purepure:zbasicbasic"):
Image
PS: I just discovered that if you create a window in form designer with the Mac display in HiDPI mode, in code view you get the width and height halved :cry:
AZJIO
Addict
Addict
Posts: 2223
Joined: Sun May 14, 2017 1:48 am

Re: TextGadget & spaces

Post by AZJIO »

Piero wrote: Fri Feb 14, 2025 12:49 am 160 should be good for win too…
I have a large font, so if a programmer uses the width of the gadget for a font of 8.5, then with a font of 10 or 11 it will definitely go beyond the limits. If a flag prohibiting line breaks is used, then I will lose a couple of letters and understand the meaning of the word, otherwise the whole word will be moved and I will lose the meaning.
If the gadget's text in TextGadget consists of more than one word, then I try to use the #SS_LEFTNOWORDWRAP flag.
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

Re: TextGadget & spaces

Post by Piero »

Well, I thought it could be the font too, but in this case "160" is just the "physical" limit of the window
User avatar
Piero
Addict
Addict
Posts: 1040
Joined: Sat Apr 29, 2023 6:04 pm
Location: Italy

P.S.

Post by Piero »

On my Mac it doesn't seem to "go to new line" in form designer, but it does when you run the code :cry: :cry: :cry:
Post Reply