ListIconGadget column text

Share your advanced PureBasic knowledge/code with the community.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

ListIconGadget column text

Post 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).
Last edited by Dude on Sun Feb 18, 2018 5:05 am, edited 1 time in total.
User avatar
Zebuddi123
Enthusiast
Enthusiast
Posts: 794
Joined: Wed Feb 01, 2012 3:30 pm
Location: Nottinghamshire UK
Contact:

Re: ListIconGadget column text

Post 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
malleo, caput, bang. Ego, comprehendunt in tempore
User avatar
Fangbeast
PureBasic Protozoa
PureBasic Protozoa
Posts: 4747
Joined: Fri Apr 25, 2003 3:08 pm
Location: Not Sydney!!! (Bad water, no goats)

Re: ListIconGadget column text

Post 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")
Amateur Radio, D-STAR/VK3HAF
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: ListIconGadget column text

Post 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
Wolfram
Enthusiast
Enthusiast
Posts: 567
Joined: Thu May 30, 2013 4:39 pm

Re: ListIconGadget column text

Post by Wolfram »

What does the ~ operation do in this case?
macOS Catalina 10.15.7
wilbert
PureBasic Expert
PureBasic Expert
Posts: 3870
Joined: Sun Aug 08, 2004 5:21 am
Location: Netherlands

Re: ListIconGadget column text

Post 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
Windows (x64)
Raspberry Pi OS (Arm64)
IdeasVacuum
Always Here
Always Here
Posts: 6425
Joined: Fri Oct 23, 2009 2:33 am
Location: Wales, UK
Contact:

Re: ListIconGadget column text

Post by IdeasVacuum »

Hi Dude - 200 entries - why not do that with a little loop instead of typing it all by hand?
IdeasVacuum
If it sounds simple, you have not grasped the complexity.
Dude
Addict
Addict
Posts: 1907
Joined: Mon Feb 16, 2015 2:49 pm

Re: ListIconGadget column text

Post by Dude »

They're not loopable items. :) They're all custom individual text, with each one not related to any other.
Post Reply