Text Lists: Setting the chosen item programmatically


#1

When opening a form with a text list, I’d like to have the first item in the text list selected. The current behavior upon opening the form is that the text list has no selection. I haven’t discovered any way to select a text list row programmatically. Does anyone have any ideas about how to do this, or whether it can be done? I haven’t found anything in this forum or in the documentation describing such a solution.


#2

You can use the Form Event Procedure method in the Form Properties panel to select the first item in the list. The Text List must have a name and the data value for the selection must also be set with a field or variable. In my example below I have named the Text List “myList” and the data selection variable is named “theSelection”. In the Form Event Procedure I have entered this code"

if info("formevent") match "open"
	objectaction "myList", "GetList", theSelection
	theSelection=array(theSelection,1,cr())
	showvariables theSelection
Endif

In Panorama 6 the List Object had a “SelectCell” command that you could set to 1 and have the first cell selected but this does not seem to function in Panorama X. Therefore, I had to first get the entire list contents and then grab the first item with the array( function to set the data variable to the contents of the first line item. This procedure will be triggered and fully executed whenever the form is opened. If you want this to happen any time the form is frontmost (including when it is first opened) you would substitute “front” in place of “open” for the info(“formevent”) function.

Here is a screen shot of my example form:


#3

If your text list object has the option “Database Navigator” activated in the Properties, then the text list will always highlight the entry of the current record. If you want to highlight the first element, click on the First Record button in the toolbar or use firstrecord in your procedure code.
04


#4

The answer depends on how the Text List is set up. As Kurt has pointed out, if the database navigator option is enabled, the record is automatically selected based on the database position. I’m guessing the original poster was not using this option.

If the Text List is linked to a variable, you can control the selected row by changing that variable and then using the showvariables statement, just as you would for a Text Editor, Popup Menu or other object that displays data. This is much simpler than it was in Panorama 6, where special commands were needed


#5

Thank you, that works!

One additional question … How can I find out what command parameters, such as “GetList”, are appropriate for “objectaction”?

Obviously, each object is likely to have different parameters. Where can I find an authoritative list of these? For Text Lists, the “GetList” parameter is not listed in the help files.


#6

The old Panorama 6 pdf file called Formulas & Programming has a Chapter 3 titled Programming Techniques with a subsection of Program Control of SuperObjects™ starting on page 666 (yikes!). In there it lists all the recognized commands for the various Pan 6 SuperObjects. Unfortunately, many of these various commands have not been carried over to Pan X so the only way to know for sure is to try them in Pan X. I wish there was a current listing of implemented commands for the various objects available in Panorama X.

The Formulas & Programming.pdf file can still be downloaded from ProVue at http://www.provue.com/classic/Formulas%20&Programming.pdf.


#7

For Panorama X 10.1 or newer, I would recommend changing this code:

if info("formevent") match "open"
     objectaction "myList", "GetList", theSelection
     theSelection=array(theSelection,1,cr())
     showvariables theSelection
Endif

to this:

formOPEN:
     objectaction "myList", "GetList", theSelection
     theSelection=array(theSelection,1,cr())
     showvariables theSelection
     return

There was a lot of changes in 10.1, so this change was easy to miss in the long release notes (it’s there, though). But the new method is easier and has better performance. It is described on this page.

Also, the second line of code could be:

    theSelection=firstline(theSelection)

No difference, just possibly a bit easier to read, and fewer keystrokes.

One other point, you may not need the objectaction getlist code. Instead, you could just use the same formula that is used in the text list. So something like this:

formOPEN:
    theSelection=firstline(theTextListFormula)
    showvariables theSelection
    return

#8

Thank you for your responses. They have been most helpful.