Arbortext Command Language > Using the Arbortext Command Language > Example: List Response Panel
  
Example: List Response Panel
You can create any number of non-blocking list response panels using window_create. The window_set function is used to change various attributes of the panel, for example:
the list of items to display
the label at the top of the panel
the default input item
the function to call when a button is pressed
the labels displayed on the buttons
The scrolling list may be set from an array or appended one item at a time. The callback function has complete control over the behavior of the window when a button is pressed. For example, it can choose to unmap the window (for reuse), destroy it, or display a message and leave the window up.
Here is an example.
function list_callback(win, but, seln, pos)
{
if (but == 3)
{
# HELP
window_set(win, "message", "Pick any number");
}
else if (but == 2)
{
# APPLY: leave panel up
# ... do something here with $seln
}
else if (but == 1)
{
# OK
# take down window, but don't destroy it for reuse
window_show(win, 0);
# ... do something here with $seln}
else
{
# else 0 (CANCEL) or -1 (window manager quit)
window_destroy(win);
}
return 0;
}
function pickanum()
{
local w, X[]
# make an array of items
split("one two three four", X)
w = window_create("list")
window_set(w, "items", X, "default", X[2], \
"title", "Pick a Number", \
"callback", "list_callback")
window_show(w, 1);
return w;
}