Re: TreeView custom sort?

2016-12-10 Thread Richard Gaskin

Matt Maier wrote:

> Do you need the user to be able to interact with each named object
> individually through the TreeView widget? If not, maybe you can just
> replace the single object name with a list of all relevant objects in
> your preferred sort order. You'd still get a hierarchy of groups that
> way. You could just "open" the list in a list field to address an
> individual object.

Now it's my turn:  I have no idea what that means. :)

But if it helps, the control will be a selector, so I will need to allow 
the user to click each element in the tree to select it.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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: TreeView custom sort?

2016-12-10 Thread Matt Maier
Do you need the user to be able to interact with each named object
individually through the TreeView widget? If not, maybe you can just
replace the single object name with a list of all relevant objects in your
preferred sort order. You'd still get a hierarchy of groups that way. You
could just "open" the list in a list field to address an individual object.

On Sat, Dec 10, 2016 at 10:33 AM, Richard Gaskin  wrote:

> Tore Nilsen wrote:
>
> > Could you build the initial array with the object names as keys, add
> > the layer numbers as part of the information you store about each
> > element,  then sort the array by layer numbers and set the array of
> > the tree view widget to the sorted array?
>
> Ah, but arrays aren't sortable per se.
>
> We can sort the keys of an array, but what we're doing there is sorting a
> delimited chunk.
>
> Associative arrays have no internal representation of order, so no matter
> what I do with the keys the array itself will remain a hash table of
> unpredictable order.
>
> I could prepend the top-level array key with a number, but this has two
> drawbacks:
>
> 1. Not being purely numeric, it can only sort alphabetically, producing
> things like this:
>
> 1 First item
> 11 Eleventh item
> 2 Second item
>
> 2. I'd prefer not to have the numbers visible to the user at all, since
> they would be just an artifice used for sorting and have no semantic
> meaning in my UI.
>
> If the TreeView offered options for using custom sort functions that might
> work well, esp. if I could alter keys as it goes so I could remove the
> numeric portion.  But at the moment I don't believe it does.
>
>
> --
>  Richard Gaskin
>  Fourth World Systems
>  Software Design and Development for the Desktop, Mobile, and the Web
>  
>  ambassa...@fourthworld.comhttp://www.FourthWorld.com
>
> ___
> 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: TreeView custom sort?

2016-12-10 Thread Richard Gaskin

Tore Nilsen wrote:

> Could you build the initial array with the object names as keys, add
> the layer numbers as part of the information you store about each
> element,  then sort the array by layer numbers and set the array of
> the tree view widget to the sorted array?

Ah, but arrays aren't sortable per se.

We can sort the keys of an array, but what we're doing there is sorting 
a delimited chunk.


Associative arrays have no internal representation of order, so no 
matter what I do with the keys the array itself will remain a hash table 
of unpredictable order.


I could prepend the top-level array key with a number, but this has two 
drawbacks:


1. Not being purely numeric, it can only sort alphabetically, producing 
things like this:


1 First item
11 Eleventh item
2 Second item

2. I'd prefer not to have the numbers visible to the user at all, since 
they would be just an artifice used for sorting and have no semantic 
meaning in my UI.


If the TreeView offered options for using custom sort functions that 
might work well, esp. if I could alter keys as it goes so I could remove 
the numeric portion.  But at the moment I don't believe it does.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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: TreeView custom sort?

2016-12-10 Thread Richard Gaskin

Matt Maier wrote:

> On Sat, Dec 10, 2016 at 9:30 AM, Richard Gaskin wrote:
>
>> I need a sort of object browser, and have been playing around with
>> the TreeView widget as a possible quick solution.
>>
>> Handy for many things, but being array-based it seems my options for
>> sorting are limited.
>>
>> Like the IDE's Object Browser, I need a sort order which reflects
>> physical layering of objects.
>>
>> I could number these as I add them to the array, but the numbers
>> would be meaningless to the user, as they would be in the Object
>> Browser.
>>
>> I'd like to show the object name instead, but I can't find a way to
>> do that while maintaining a fixed order.
>>
>> Any ideas, or am I back to making a custom control for this?
>
> I used rTree when I was trying to find a pre-built tree tool. It's
> pretty good.

I like rtree, but my needs are modest enough that I prefer to use a 
single object for such things when I can.


I've made tree viewers before with a single field, and may do that again 
if I can't get the TreeView widget to do what I need.



> As a side note, I just want to say that it's refreshing to see you
> have a hard time explaining something ;)

If that seems rare we just don't hang out enough. :)

> So is the problem that TreeView doesn't let you control what order the
> branches are displayed in? It just dumps them out in a random order,
> or in a single order that happens to be the wrong one for your use
> case?

My question may have been sparse because it assumes the reader is 
familiar with the nature of associative arrays as being inherently 
unsorted, and also assumes my understanding that arrays are the only way 
to load the TreeView widget is correct.  Either assumption can fail. :)


Associative arrays like LiveCode's differ from indexed arrays by having 
no internal sense of order.  For getting and putting values that's fine, 
but when you need to retrieve the aggregate collection it means the 
result (such as with "get the keys of tSomeArray) will be in an 
unpredictable order.


The TreeView widget allows sorting the keys either alphabetically or 
numerically, but neither are meaningful in my UI.


With a standard list field I can put the contents in as a single chunk 
and of course the order of lines is preserved.


But since the data I'm working with is hierarchical, it would be nice to 
use a prefab object like the TreeView to display its contents, rather 
than have to use a third-party custom control like rtree or roll my own.


With a list field I have the option of having zero-width columns, so if 
I need to sort by something (say an ordinal number I use internally when 
building the list) I can do so and the user never needs to see it.


Similarly, I could use an ordinal number as the first level of the 
array, and use that for sorting only while displaying for the user only 
the subarrays.


But the TreeView doesn't seem to provide any way to hide keys or 
portions of key names, and being array-based I can think of no other 
option for maintaining a fixed order.


It may not be so bad to roll my own.  The TreeView widget doesn't seem 
to handle default keyboard actions common to hierarchical list views 
(left and right arrow keys to expand/collapse, or up and down to 
navigate) so I'd need to be doing a bit of scripting with this either way.


--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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: TreeView custom sort?

2016-12-10 Thread Tore Nilsen
Could you build the initial array with the object names as keys, add the layer 
numbers as part of the information you store about each element,  then sort the 
array by layer numbers and set the array of the tree view widget to the sorted 
array? Or am I missing something in your description here? 

Regards
Tore Nilsen


> 10. des. 2016 kl. 18.30 skrev Richard Gaskin :
> 
> I need a sort of object browser, and have been playing around with the 
> TreeView widget as a possible quick solution.
> 
> Handy for many things, but being array-based it seems my options for sorting 
> are limited.
> 
> Like the IDE's Object Browser, I need a sort order which reflects physical 
> layering of objects.
> 
> I could number these as I add them to the array, but the numbers would be 
> meaningless to the user, as they would be in the Object Browser.
> 
> I'd like to show the object name instead, but I can't find a way to do that 
> while maintaining a fixed order.
> 
> Any ideas, or am I back to making a custom control for this?
> 
> -- 
> Richard Gaskin
> Fourth World Systems
> Software Design and Development for the Desktop, Mobile, and the Web
> 
> ambassa...@fourthworld.comhttp://www.FourthWorld.com
> 
> ___
> 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: TreeView custom sort?

2016-12-10 Thread Matt Maier
I used rTree when I was trying to find a pre-built tree tool. It's pretty
good.
I think I actually got some code straight from the dev that wasn't posted
publicly. I haven't used it in a long time.
http://tapirsoft.on-rev.com/rtree/

As a side note, I just want to say that it's refreshing to see you have a
hard time explaining something ;) I rewrote this reply a few times as I
gradually figured out what you're asking for.

So is the problem that TreeView doesn't let you control what order the
branches are displayed in? It just dumps them out in a random order, or in
a single order that happens to be the wrong one for your use case?

Maybe there's a way to get it to sort by an invisible character? One that
affects the sort but isn't actually displayed on screen?

On Sat, Dec 10, 2016 at 9:30 AM, Richard Gaskin 
wrote:

> I need a sort of object browser, and have been playing around with the
> TreeView widget as a possible quick solution.
>
> Handy for many things, but being array-based it seems my options for
> sorting are limited.
>
> Like the IDE's Object Browser, I need a sort order which reflects physical
> layering of objects.
>
> I could number these as I add them to the array, but the numbers would be
> meaningless to the user, as they would be in the Object Browser.
>
> I'd like to show the object name instead, but I can't find a way to do
> that while maintaining a fixed order.
>
> Any ideas, or am I back to making a custom control for this?
>
> --
>  Richard Gaskin
>  Fourth World Systems
>  Software Design and Development for the Desktop, Mobile, and the Web
>  
>  ambassa...@fourthworld.comhttp://www.FourthWorld.com
>
> ___
> 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


TreeView custom sort?

2016-12-10 Thread Richard Gaskin
I need a sort of object browser, and have been playing around with the 
TreeView widget as a possible quick solution.


Handy for many things, but being array-based it seems my options for 
sorting are limited.


Like the IDE's Object Browser, I need a sort order which reflects 
physical layering of objects.


I could number these as I add them to the array, but the numbers would 
be meaningless to the user, as they would be in the Object Browser.


I'd like to show the object name instead, but I can't find a way to do 
that while maintaining a fixed order.


Any ideas, or am I back to making a custom control for this?

--
 Richard Gaskin
 Fourth World Systems
 Software Design and Development for the Desktop, Mobile, and the Web
 
 ambassa...@fourthworld.comhttp://www.FourthWorld.com

___
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