Multiple Choice List Gadgets
- Last UpdatedJan 09, 2024
- 2 minute read
You can read the current selections in a multiple-choice list using the selection() methods. This will return the replacement-texts:
!Xarray = !This.List.selection() ‑ returns selected replacement texts by default
!Xarray = !This.List.selection(‘Dtext’) ‑ returns selected display texts
To read the index numbers of the currently selected fields of a multi-choice list gadget:
!ChosenNumbersArray = !!Form.List.Val
You can read back the current Dtexts or Rtexts as an array or simply as strings:
!array = !This.List.Dtext ‑ get all the Dtexts
!string = !This.List.Rtext[3] ‑ get Rtext of the third list field
You can select fields of this list either singly (additive) or by array of Dtext or Rtext, using its select() methods:
!This.List.select(‘Rtext’, ‘Tea’)
!This.List.select(‘Dtext’, !array)
Callbacks on Multi-Choice List Gadgets
At PDMS11.6 we introduced support for Extended Selection Mode for multi-selection lists, whereby CTRL and SHFT keys can qualify the list selection. As a result a whole set of UNSELECT events followed by a whole set of SELECT events can result from a single (atomic) user action. These events are presented in sequence, but AppWare cannot tell where the sequence starts or ends.
At PDMS11.6, problems may arise if a multi-selection list is programmatically changed during the list callback. Modifying the list content or its selection during the sequence can cause unexpected results or even software crashes.
At PDMS11.6Sp1 we nave introduced new START and STOP batch actions to bracket the sequence of UNSELECT and SELECT event actions.
For maximum upwards compatibility, the START and STOP batch actions are only notified to PML if the user has assigned an open callback, since this is the only way that different event types (actions) can be differentiated.
AppWare which used simple callbacks and worked at PDMS11.6 will continue to work because START and STOP events will not be notified to it.
AppWare which used open callbacks and worked at PDMS11.6 will continue to work if the SELECT and UNSELECT meta-events were explicitly differentiated in the callback, as shown below, because the new START and STOP events will be ignored
Define method .listSelectionChanged( !list is GADGET, !action is STRING )
. . .
if( !action eq ‘SELECT’ ) then
. . .
elseif( !action eq ‘UNSELECT’ then
. . .
endif
. . .
endmethod
If you experience a change in behavior, then you may need to rewrite your callback to explicitly handle the new START and STOP events and modify the list content or its selection only on receiving the STOP event action.
For newly written AppWare we strongly advise you use open callbacks to service multi-selection list gadgets.