Bold or Change Text color of various lines in Tree View?

LiveCode is the premier environment for creating multi-platform solutions for all major operating systems - Windows, Mac OS X, Linux, the Web, Server environments and Mobile platforms. Brand new to LiveCode? Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Bold or Change Text color of various lines in Tree View?

Post by bmcgonag » Fri Mar 27, 2020 11:56 pm

Hello,

I have a card with a tree view on it that I'm successfully filling with the data I want pulled from an API - Yay! Now, I want to use a property of "online" from the data I pull, to set the text of that associated line in the tree view to either bold, or a different color, or something to make those lines stand out better.

Here's the code I have so far:

Code: Select all

on openCard
   -- set the headers for the API call
   set the httpHeaders to "authorization: bearer <myAPIToken>"
   put "https://my.zerotier.com/api/network" into tUrl
   get url tUrl
   
   -- deal with return data - which works the way I have it here, but it seems wrong since the result isn't empty..but anyway
   
   if the result is empty then
      put it into tJSON
      put JSONtoArray(tJSON) into tArray
      
      repeat with x = 1 to the number of elements in tArray
         
         -- use the returned ID for each network to call and get the machine members of the network
         put tArray[x]["config"]["id"] into tId
         set the httpHeaders to "authorization: bearer <myAPIToken>"
         put "https://my.zerotier.com/api/network/" & tId & "/member" into t2Url
         get url t2Url
         if the result is empty then
            put it into t2JSON
            put JSONtoArray(t2JSON) into t2Array
            
            repeat with y = 1 to the number of elements in t2Array
            
               put t2Array[y]["config"]["ipAssignments"][1] into tIp
               put tArray[x]["config"]["name"] into tNetName
               put t2Array[y]["name"] into tMachName
               if t2Array[y]["online"] = true then
                  -- do something here to set bold or text color?
                  -- So far when I do something here, it gives me an error below where I'm actually adding the data to the trer view.
               end if
               put tIp into temp[tNetName][tMachname]
            end repeat
         else
            answer "Something went wrong."
         end if
      end repeat
      set the sortType of widget 1 to "text"
      set the showseparator of widget 1 to true
      set the sortOrder of widget 1 to "ascending"
      set the arraydata of widget 1 to temp
   else
      put "Something weird happened here!" into Output
   end if
end openCard
As alwas, any help or pointers is much appreciated.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Bold or Change Text color of various lines in Tree View?

Post by Klaus » Sat Mar 28, 2020 12:59 pm

An ARRAY is a variable and variable do not have a (text)STYLE property.
And there is no indication in the dictionary, so I am afraid this is just not possible.
We can only set text and styles for the whole widget.

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Bold or Change Text color of various lines in Tree View?

Post by bmcgonag » Sat Mar 28, 2020 3:10 pm

Ok, thank you.

I wonder if I can add a checkmark icon or something in the tree view some how.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Bold or Change Text color of various lines in Tree View?

Post by Klaus » Sun Mar 29, 2020 10:23 am

Hi bmcgonag,
I wonder if I can add a checkmark icon or something in the tree view some how.
I also doubt we can set an ICON here, but "something" is surely possible with a UNICODE character. :D
LC now supports UNICODE and that is just text in the end.
Something like this: ✔︎ ➡️ ❤️ 🌎...
You get the picture.


Best

Klaus

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Bold or Change Text color of various lines in Tree View?

Post by bmcgonag » Mon Mar 30, 2020 12:37 pm

I thought the same thing, but it just put :check_mark: and :smile: in the space versus showing the character. I'll look up unicode and see if I can tell what I may have done wrong.

Thank you again.

Klaus
Posts: 14177
Joined: Sat Apr 08, 2006 8:41 am
Contact:

Re: Bold or Change Text color of various lines in Tree View?

Post by Klaus » Mon Mar 30, 2020 12:45 pm

Well, this is a tad more complicated. :D

Here a little example that will put a checkmark into a field:

Code: Select all

on mouseUp
   put numtocodepoint(0x2714) into fld 1
end mouseUp

bmcgonag
Posts: 40
Joined: Thu Mar 13, 2014 6:51 pm

Re: Bold or Change Text color of various lines in Tree View?

Post by bmcgonag » Thu Apr 02, 2020 8:07 pm

Klaus wrote:
Mon Mar 30, 2020 12:45 pm
Well, this is a tad more complicated. :D

Here a little example that will put a checkmark into a field:

Code: Select all

on mouseUp
   put numtocodepoint(0x2714) into fld 1
end mouseUp
Klaus rocks! That worked beautifully!

Post Reply