SpringGUI

introduction    download    reference    examples    faq


Reference

Name

getSelectedItem(), getSelectedItems()

Examples

getSelectedItem():

void handleEvent(String[] parameters) {
  // if an item in "myList" has been selected...
  if (parameters[1].equals("myList") && parameters[2].equals("selected")) {
    // print the selected item to Processing's output
    println(gui.getSelectedItem("myList"));
  }
}


getSelectedItems():

void handleEvent(String[] parameters) {
  // assuming the List is in multiple selection mode...
  // if an item in "myList" has been selected...
  if (parameters[1].equals("myList") && parameters[2].equals("selected")) {
    // print all selected items to Processing's output
    String[] items = gui.getSelectedItems("myList");
    for (int i=0; i<items.length; i++) {
      println(items[i]);
    }
  }
}

Description

getSelectedItem() returns the selected item in a single selection mode List or in a Choice element.
getSelectedItems() returns all selected items in a multiple selection mode List element.

Syntax

String item = gui.setSelectedItem(name); String[] items = gui.setSelectedItems(name);

Parameters

String name getSelectedItem()
The name of the List or Choice element.
getSelectedItems()
The name of the multiple selection mode List element.

Returns

getSelectedItem()
The selected item in the List or Choice element.
getSelectedItems()
A String array of all selected items in the multiple selection mode List element.

Will return null if the element specified by name is of the wrong type or non-existant.

Related

isListMultipleMode(), setListMultipleMode()
selectItem()
addItem()
removeItem()
hasItem()
getItemCount()
getItemByIndex()
addChoice()
addList()
table of events


back to the top of the page


tinkering with codetools and docsscrapbookabout