Selecting Multiple Text List items when you expected only one

I discovered a quirk in the Text List selection value, but maybe it’s a feature(?).
Suppose you have a text list that displays the array A,B,C,A,C,D, and you select the first row. I would have expected that the selected value would be A, but in fact, you get both As, with a carriage return.
Of course, you can easily account for this if you only want one with an array statement. In legal parlance, we call this a trap for the unwary. Here’s what the text list looks like:

The Text List object selects by value, not by position in the list. Since your list contains duplicate items with the same value, you cannot select just one of these items independently.

One thing I noted about the Text List Object is that if you have it set for multiple selections and someone selects all items (obviously not a common occurrence), there is no way I found to then unselect items unless you change the linked variable or field containing the selected list with a procedure. I guess you would need to put a Clear button by such a Text List just in case someone actually does select all items.

Can’t you hold down the Command key and click to toggle an item? I think that will work.

That didn’t work for me - everything remained selected.

You’re right, my mistake.

If the list is shorter than the object, you can click on the empty space below the list. Otherwise, the only way to reset it is with a program, possibly linked to a button as you suggest.

If you don’t want to add a button you could link that unselection program to a header click.

Good point John, as long as you have a header available. I really think the command-click should be available to unselect a selected item the same as that action functions in the Finder (command-click will select additional items if currently unselected or unselect them if they are already selected).

I’d agree. Selection in Text List Objects, at least when multiple selections is checked, should work like Finder selections in keeping with Jim’s drive to provide a standard Mac interface. I don’t know whether that’s achievable—maybe Apple’s tools aren’t as consistent as we’d hope—but when the code surprises Jim it may be worth a moment of his alleged spare time to peek there.

The worst case scenario besides having all items selected and being locked out is when there is a rather lengthy list and someone is going through command-clicking items here and there and then inadvertently command-clicks the wrong item. Now there is no way to eliminate the miss-clicked item without clearing all the current selections and starting over. :angry:

I’ve added this to the list of issues to investigate. This frustrates me as well. The puzzling part is that Panorama is using Apple’s standard NSTable API’s for this, Panorama doesn’t even handle the click at all. I’m quite surprised Apple doesn’t handle this the way we expect. So I will look into seeing how this can be overridden.

1 Like

What mystifies me about this is that it works correctly in Numbers.

You could write a procedure that would delete the clicked-on value with an option-click. Suppose there is an array: replace(“A,B,C,A,D,E”,",",cr())
and the data variable is fgtlvalue, then this code will delete a clicked-on value:

if optionclick()
     let lvvaluetodelete=array(replace("A,B,C,A,D,E",",",cr()),
          info("matrixrow"),cr())  //Gets the value to deselect
     fgtlvalue=arrayfilter(fgtlvaluesaved,cr(),|||?(import()≠
          lvvaluetodelete,import(),"")|||) //filters out the value
          being deselected
     showvariables fgtlvalue
endif
letfileglobal fgtlvaluesaved=fgtlvalue  //This variable is needed in 
      case the user option-clicks on an empty row

I don’t think there is a commandclick( function, so I don’t see how that could be used to deselect an already selected value. If there were, then you could use it to toggle the selection of a value.

Apple software doesn’t always use the built-in macOS code.

Which is probably why the bug has not been fixed. If they are not using the code, end users will not find it, and it is less likely to get reported.