Tree Widget: hilitedValue?

Brian Milby brian at milby7.com
Sat Jul 9 20:11:29 EDT 2022


I don't think there is an existing one liner, but it can be done a couple
ways.

Here is a recursive function defined in the PI code for Custom Props:

on fetchArrayDataOnPath pPath, pArray, @rData
   local tKey
   put item 1 of pPath into tKey
   if the number of items in pPath is 1 then
      if tKey is not among the keys of pArray then
         return "no such key"
      else
         put pArray[tKey] into rData
         return empty
      end if
   else
      delete item 1 of pPath
      fetchArrayDataOnPath pPath, pArray[tKey], rData
   end if
end fetchArrayDataOnPath

There are other handlers in that script that could be useful as well
(add/set/delete).

You could also turn the path into an array (but lose the error checking
above):

function getValue pArray, pPath
   split pPath by comma
   return pArray[pPath]
end getValue

Thanks,
Brian

On Sat, Jul 9, 2022 at 5:08 PM J. Landman Gay via use-livecode <
use-livecode at lists.runrev.com> wrote:

> On 7/9/22 3:17 PM, J. Landman Gay via use-livecode wrote:
> > On 7/8/22 12:34 PM, Richard Gaskin via use-livecode wrote:
> >> I see the Tree widget supports a hilitedElement property, which is
> useful for managing the
> >> selection in the UI.
> >>
> >> Is there a one-liner for obtaining not the element path but the value?
> >
> > I'm using an older version, but here the hilitedElement includes the
> values of each element in
> > the path.
> >
>
> I misunderstood, you don't mean just the names of the elements. The value
> shows up as part of
> the tree unless you turn off "show values". I think you'll have to parse
> the array to actually
> get the values in a leaf.
>
> --
> Jacqueline Landman Gay         |     jacque at hyperactivesw.com
> HyperActive Software           |     http://www.hyperactivesw.com
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>


More information about the use-livecode mailing list