Page 1 of 1

ListIconGadget column text

Posted: Sun Feb 18, 2018 1:43 am
by Dude
Maybe this is common knowledge, but I only just realized it today. :shock:

For years now, I've been adding items to multiple ListIconGadget columns using "+#LF$+", which is a royal pain the butt to type, especially when my ListIconGadget has over 200 hard-coded items with descriptions in it. :(

It also meant whenever I accidentally deleted a quote, the text in the descriptions would convert to PureBasic syntax ("and" became "And", etc) which I then had to go and manually correct. Basically, it wasn't an enjoyable typing experience.

Code: Select all

AddGadgetItem(gad,-1,"Column1"+#LF$+"Column2"+#LF$+"Column3") ; Yuck!
Today I found out I can do it more simply like this:

Code: Select all

AddGadgetItem(gad,-1,~"Column1\nColumn2\nColumn3") ; Awesome!
No quotes to accidentally delete, and no need to type a bunch of "+#LF$+" in there. :D

Hope this helps somebody else! Time to search/replace all my sources. ;)

[Edit] Just watch out that if any column text contains a backslash (like C:\Test.txt) then you'll need to convert it to double-backslashes to stay valid (C:\\Test.txt).

Re: ListIconGadget column text

Posted: Sun Feb 18, 2018 2:25 am
by Zebuddi123
Hi Dude Yes it does Thank You.

At least that`s one thing I can wake up to tomorrow morning, that`s far better looking than yesterday :oops: :lol: :lol: :lol: :lol: :lol: :shock:

Zebuddi. :D

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 1:23 pm
by Fangbeast
I just tried this with the word "chicken" and the first letter of every word turned into an upward pointing arrow?

What am I missing here?

AddGadgetItem(gad,-1,~"chicken\chicken\chicken")

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 1:43 pm
by Dude
Fangbeast wrote:AddGadgetItem(gad,-1,~"chicken\chicken\chicken")
You have to use "\n" and not just a backslash alone:

Code: Select all

OpenWindow(0,200,200,400,100,"test",#PB_Window_SystemMenu)

ListIconGadget(0,10,10,380,80,"C1",100)
AddGadgetColumn(0,1,"C2",100)
AddGadgetColumn(0,2,"C3",100)

AddGadgetItem(0,-1,~"Chicken\nChicken\nChicken")

Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 2:06 pm
by Wolfram
What does the ~ operation do in this case?

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 3:52 pm
by wilbert
Wolfram wrote:What does the ~ operation do in this case?
It’s explained in the manual (Literal strings section)
https://www.purebasic.com/documentation ... rules.html

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 4:22 pm
by IdeasVacuum
Hi Dude - 200 entries - why not do that with a little loop instead of typing it all by hand?

Re: ListIconGadget column text

Posted: Tue Feb 20, 2018 10:08 pm
by Dude
They're not loopable items. :) They're all custom individual text, with each one not related to any other.