OpenMusic

Visual Programming | Computer-Assisted Composition

Navigation : Previous | Next

Selecting Items and Triggering Actions: Pop-Up Menu Box

Contents

  1. Features
  2. Settings
  3. Uses
  4. A Musical Application : an Extended Example

The pop-up-menu box allows to

To some extent, it resembles the items-list boxes.

Features

Inputs

The pop-up-menu box has two inputs :

—|—

Outputs

The two outputs are independent from the inputs :

Settings

Menu

To set the menu items, edit the first input, select the box and evaluate.

Selected Item Value

Click on the menu to select an item. When the box is evaluated :

Locking the Menu

Mind locking the box before the evaluation : otherwize, the selected item might be reinitialized (by default to the first item in the list).

Uses

Tip : Selecting Files

Using a directory to initialize the menu contents.

Using a directory to initialize the menu contents.

The pop-up-menu box can be useful for selecting files in a folder.

Connect a folder pathname to the first output of the pop up box : the menu items will stand for the files contained in the folder.

The infile and outfile boxes are designed to return a directory pathname to the files contained in the in-files and outfiles folder of the current workspace. They can be connected to the pop-up-menu to list and select files in these folders.

—|—

Triggering an Operation

The second input of the menu can be used for triggering an operation using the selected item as parameter. This input must be connected to a function or a box on “lambda” mode with one input or argument.

To set or modify the function associated with the menu, connect a box or function, then evaluate the box .

The lambda function is called when an item is selected.

The index of this item is the number returned by the first output. It is the argument of the function.

The value of the selected item – a number between 0 and 2 – is printed in
the listener at selection.

The value of the selected item - a number between 0 and 2 - is printed in the listener at selection.

—|—

A Musical Application : an Extended Example

Choosing and Listening to a Sound with a Pop-Up-Menu Box

References :

Contents :

Navigation : Previous | Next