Re: Tree View Values

2018-08-30 Thread Brian Milby via use-livecode
There is already a PR merged into 9.1 that will auto select the text of any
field in the PI when you enter it via tab.  This also selects the key field
in the Custom Properties inspector when the highlight changes.  If you tab
into the value, then the value is selected.

Changing the logic to select a non-empty value field in the PI probably
wouldn't be that hard, but would then introduce a difference in behavior
that may not always be desirable.

Having a new key when added get selected is the next thing I'm working on,
but that is proving to be a little bit more of a challenge.  Having the
tree widget highlight a new sub-key was easy.  Top level keys are proving
to be a little more difficult.  The current PI code doesn't like the
highlight change though.

Brian

On Thu, Aug 30, 2018 at 11:50 AM Bob Sneidar via use-livecode <
use-livecode@lists.runrev.com> wrote:

> Hi Brian.
>
> Actually for my purposes I need the last key of the array node. For
> example, if I have an array:
>
> myArray [level1] [level2] [level3]
>
> and the value is "Test1"
>
> then I need to return an array:
>
> aArrayNode [level3]
>
> I worked it out using my method so I'm not asking for a modification to
> your method, this for informational purposes only. What I am actually
> creating is an XML editor using a tree view, and also I am creating a
> method for solving the Property Inspector issue some have raised, where
> clicking a tree node does not hilite the node name or the value if there is
> one.
>
> What I am doing is almost identical to what the the property inspector
> does. I've worked it out so that hiliting a tree node whose value is an
> array puts the name of the hilited node into the Key field, selects the
> text of the key field, and puts empty into the Value field. If however the
> value of the hilited node is a value, it puts the value into the Value
> field and selects the text of the value field. This IMHO is the way the
> property inspector *ought* to work.
>
> Bob S
>
>
> > On Aug 30, 2018, at 07:41 , Bob Sneidar via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >
> > Oh there you go! That works.
> >
> > Bob S
> >
> >
> >> On Aug 29, 2018, at 13:58 , Brian Milby via use-livecode <
> use-livecode@lists.runrev.com> wrote:
> >>
> >> Here is another way to do it:
> >>
> >> function getHilightedValue pTreeWidgetReference
> >>  local tElement, tArray
> >>  put the arrayData of pTreeWidgetReference into tArray
> >>  put the hilitedElement of pTreeWidgetReference into tElement
> >>  split tElement by comma
> >>  return tArray[tElement]
> >> end getHilightedValue
>
> ___
> use-livecode mailing list
> use-livecode@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Tree View Values

2018-08-30 Thread Bob Sneidar via use-livecode
Hi Brian. 

Actually for my purposes I need the last key of the array node. For example, if 
I have an array:

myArray [level1] [level2] [level3]

and the value is "Test1"

then I need to return an array:

aArrayNode [level3]

I worked it out using my method so I'm not asking for a modification to your 
method, this for informational purposes only. What I am actually creating is an 
XML editor using a tree view, and also I am creating a method for solving the 
Property Inspector issue some have raised, where clicking a tree node does not 
hilite the node name or the value if there is one. 

What I am doing is almost identical to what the the property inspector does. 
I've worked it out so that hiliting a tree node whose value is an array puts 
the name of the hilited node into the Key field, selects the text of the key 
field, and puts empty into the Value field. If however the value of the hilited 
node is a value, it puts the value into the Value field and selects the text of 
the value field. This IMHO is the way the property inspector *ought* to work. 

Bob S


> On Aug 30, 2018, at 07:41 , Bob Sneidar via use-livecode 
>  wrote:
> 
> Oh there you go! That works.
> 
> Bob S
> 
> 
>> On Aug 29, 2018, at 13:58 , Brian Milby via use-livecode 
>>  wrote:
>> 
>> Here is another way to do it:
>> 
>> function getHilightedValue pTreeWidgetReference
>>  local tElement, tArray
>>  put the arrayData of pTreeWidgetReference into tArray
>>  put the hilitedElement of pTreeWidgetReference into tElement
>>  split tElement by comma
>>  return tArray[tElement]
>> end getHilightedValue

___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Tree View Values

2018-08-30 Thread Bob Sneidar via use-livecode
Oh there you go! That works.

Bob S


> On Aug 29, 2018, at 13:58 , Brian Milby via use-livecode 
>  wrote:
> 
> Here is another way to do it:
> 
> function getHilightedValue pTreeWidgetReference
>   local tElement, tArray
>   put the arrayData of pTreeWidgetReference into tArray
>   put the hilitedElement of pTreeWidgetReference into tElement
>   split tElement by comma
>   return tArray[tElement]
> end getHilightedValue


___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Tree View Values

2018-08-29 Thread Brian Milby via use-livecode
Here is another way to do it:

function getHilightedValue pTreeWidgetReference
   local tElement, tArray
   put the arrayData of pTreeWidgetReference into tArray
   put the hilitedElement of pTreeWidgetReference into tElement
   split tElement by comma
   return tArray[tElement]
end getHilightedValue
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Re: Tree View Values

2018-08-29 Thread Brian Milby via use-livecode
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@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@lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>
___
use-livecode mailing list
use-livecode@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode


Tree View Values

2018-08-29 Thread Bob Sneidar via use-livecode
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@lists.runrev.com
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode