Tree View Values

Brian Milby brian at milby7.com
Wed Aug 29 16:35:44 EDT 2018


Here is the handler from the PI:

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


On Wed, Aug 29, 2018 at 2:52 PM Bob Sneidar via use-livecode <
use-livecode at lists.runrev.com> wrote:

> Hi all.
>
> Anyone working with tree views will immediately encounter an oddity, where
> the hilitedElement returns a comma delimited list of the array keys to the
> clicked item in the tree view. A comma delimited list of keys is almost
> completely useless if you want to get the value of the actual item clicked
> on! If the item is an array, it will return that of course.
>
> So I wrote a little function for getting the "actual" value of the key in
> the array corresponding to the selected item. There may be another way to
> do this baked into the XML library, but I could not discern it.
>
> Bob S
>
> on hiliteChanged
>    -- this goes into your tree widget script
>    local tElement
>    put the arrayData of me into aTreeData
>    put the hilitedElement of the target into tElement
>    put getArrayKeyValueFromKeyList(aTreeData, tElement) into tKeyValue --
> now you have the value
>    pass hiliteChanged
> end hiliteChanged
>
>
> function getArrayKeyValueFromKeyList aArray, pKeyList
>    -- this can go anywhere in the message path
>    repeat for each item tKey in pKeyList
>       put "[" & quote & tKey & quote & "] " after tArrayKey
>    end repeat
>
>    put "aArray" && tArrayKey into tArrayElement
>    return value(tArrayElement)
> end getArrayKeyValueFromKeyList
>
>
>
> _______________________________________________
> 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