Select a line of a list box

MINI LESSONS ›› Actions Editor ››

MINI LESSON

How to select a line of a list box using the Actions Editor

A single select list box and multi select list box field do have the ability to allow you to determine which lines are currently selected or even programmatically set which lines are selected. This is done by manipulating the ItemSelected property of the list box.




The ItemSelected property is implemented within ToolBook as an array.



Note that the array is a 0 based array so technically element 0 of the array is textline 1, element 1 of the array is textline 2 and so on.


Each element of the array holds the value of True or False. If the line is currently selected the value will be true, otherwise the value will be false.


In order to access this Array property you first have to copy it into an Array variable.




You are permitted to replace this ItemSelected property with an entirely different array or you can individually update only certain elements (lines) of the list box.

Example

Consider a list box with 3 lines in it:


  Apple

  Pear

  Banana


If I want to see if "Banana" [which is text line 3] is selected using the Actions Editor, code similar to this would be used:


  set myTempArray to itemSelected of field "theListBox"

  if myTempArray[2] = true

    -- yes it is selected

  end if


If I want to ensure that "Pear" [which is text line 2] is selected using the Actions Editor, code similar to this would be used:


  set myTempArray to itemSelected of field "theListBox"

  set myTempArray[1] to true

  set itemSelected of field "theListBox" to myTempArray



Created with the Personal Edition of HelpNDoc: Produce electronic books easily