TreeGadget truncating long strings

Just starting out? Need help? Post your questions and find answers here.
Quin
Addict
Addict
Posts: 1144
Joined: Thu Mar 31, 2022 7:03 pm
Location: Colorado, United States
Contact:

TreeGadget truncating long strings

Post by Quin »

I have this code:

Code: Select all

EnableExplicit

OpenWindow(0, 0, 0, 400, 400, "Test")
TreeGadget(0, 0, 0, 400, 400)
AddGadgetItem(0, -1, "This is an incredibly long string, and it'll most likely get cut off at some point in the very near future. I'm still uncertain if this is a  PB bug or a Windows one, although I have seen certain listboxes do the exact same thing so I'm beginning to wonder if it actually is a Windows thing.", 0, 0)
SetGadgetState(0, 0)
SetActiveGadget(0)
Repeat : Until WaitWindowEvent(1) = #PB_Event_CloseWindow
At least on Windows using a screen reader, the text gets cut off around the word "wonder". Has anyone hit this, and if so is there a way around it?
Thanks!
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: TreeGadget truncating long strings

Post by RASHAD »

I tried it with Windows API
This is Windows limitation NOT PB
Egypt my love
AZJIO
Addict
Addict
Posts: 2227
Joined: Sun May 14, 2017 1:48 am

Re: TreeGadget truncating long strings

Post by AZJIO »

Code: Select all

EnableExplicit

Global NewList Book.s()
Global *tmp, *tmp2, Item

OpenWindow(0, 0, 0, 400, 400, "Test")
TreeGadget(0, 0, 0, 400, 400)
*tmp = AddElement(Book())
Book() = "This is an incredibly long string, and it'll most likely get cut off at some point in the very near future. I'm still uncertain if this is a  PB bug or a Windows one, although I have seen certain listboxes do the exact same thing so I'm beginning to wonder if it actually is a Windows thing."
AddGadgetItem(0, 0, Book() , 0, 0)
SetGadgetItemData(0 , 0 , *tmp)
SetGadgetState(0, 0)
SetActiveGadget(0)

Repeat
	Select WaitWindowEvent()
		Case #PB_Event_Gadget
			Select EventGadget()
				Case 0
					If EventType() = #PB_EventType_LeftClick
						Item = GetGadgetState(0)
; 						If Item <> -1
							*tmp = GetGadgetItemData(0, Item)
								; *tmp2 = SelectElement(Book(), Item) ; in this case the list index Book() and TreeGadget must match
							ResetList(Book())
							Repeat
								*tmp2 = NextElement(Book())
								If Not *tmp2
									Break
								EndIf
								If *tmp2 = *tmp
									Debug Book()
								EndIf
							ForEver
; 						EndIf
					EndIf
			EndSelect
		Case #PB_Event_CloseWindow
			CloseWindow(0)
			End
	EndSelect
ForEver
Last edited by AZJIO on Sat Dec 23, 2023 6:10 pm, edited 1 time in total.
RASHAD
PureBasic Expert
PureBasic Expert
Posts: 4995
Joined: Sun Apr 12, 2009 6:27 am

Re: TreeGadget truncating long strings

Post by RASHAD »

Workaround

Code: Select all

EnableExplicit
Define item,Quit
Dim tgtext.s(10)

OpenWindow(0, 0, 0, 400, 400, "Test",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
TreeGadget(0, 0, 0, 400, 400)
AddGadgetItem(0, -1, "This is an incredibly long string, and it'll most likely get cut off at some point in the very near future. I'm still uncertain if this is a  PB bug or a Windows one, although I have seen certain listboxes do the exact same thing so I'm beginning to wonder if it actually is a Windows thing.", 0, 0)
AddGadgetItem(0, -1, "This for test")
For item = 0 To CountGadgetItems(0)
  tgtext(item) = GetGadgetItemText(0,item)
Next
SetGadgetState(0, 0)
SetActiveGadget(0)
Repeat
 Select WaitWindowEvent(1)
  Case #PB_Event_CloseWindow
    Quit = 1
    
  Case #PB_Event_Gadget
    Select EventGadget()
      Case 0
        Select EventType()
          Case #PB_EventType_LeftClick
            Debug tgtext(GetGadgetState(0))
        EndSelect
    EndSelect
 EndSelect
Until Quit = 1
Egypt my love
AZJIO
Addict
Addict
Posts: 2227
Joined: Sun May 14, 2017 1:48 am

Re: TreeGadget truncating long strings

Post by AZJIO »

Code: Select all

        		Debug GetGadgetText(0)
;             Debug tgtext(GetGadgetState(0))
Displays a short string and returns a long one. In your example, the text for the array is taken from TreeGadget. In this case, why add it to the array if it already remains intact.
Post Reply