Problem:
This demo shows how to do an "ITEM-UNSELECTED" in a Dialog System list box
Resolution:
How to do an "ITEM-UNSELECTED" for DS list box?
Here's also a simple project to illustrate this alternative. Note that the Cobol
program doesn't actually do anything than to load the screenset and stop only
when the user clicks on the 'X' button.
There are 2 events that relate specifically to List Box:
1.
ITEM-SELECTED, invoked upon a mouse click on list box item
2.
ITEM-ACCEPTED, invoked upon a mouse double click on list box item
(or enter key pressed)
The ITEM-SELECTED event can be defined to take actions when the user clicked on a
list box item. This will also result to have that item highlighted or selected. If
the user clicked on the same item which is already selected, it doesn't do anything.
The item remains selected, and there is no event to be invoked. That is, the
ITEM-SELECTED event doesn't get invoked if the item is already selected. There
isn't either an event called "ITEM-UNSELECTED" to any other actions to be taken
if the user clicks on a selected item. What to do?
Define MOUSE-EVENT instead in the dialog for the List Box object to work around
or emulate an event to unselect an item. This will also handle the event when the
user selects an item. The purpose of the RETC's at each time an item has been
selected or unselected is just to allow a flexibility to return to the Cobol program
for any processes. Consider the following alternative:
MOUSE-EVENT
*
* Item position is moved to $REGISTER
* Mouse button action is moved to $EVENT-DATA
* where 1 is for left button depressed
* 2 is for left button released
*
* Handle the mouse button released event
IF= $EVENT-DATA 2 DO-NOTHING
GET-SELECTED-LIST-ITEM LB1 $REGISTER 0
* Handle if no item selected
IF= $REGISTER 0 DO-NOTHING
IF= $REGISTER LB-ITEM-SAV ITEM-UNSELECTED
* Save the last item selected position
MOVE $REGISTER LB-ITEM-SAV
RETC
*
ITEM-UNSELECTED
* Unselect the current item selected
SET-LIST-ITEM-STATE LB1 0 $REGISTER
MOVE 0 LB-ITEM-SAV
RETC
*
DO-NOTHING
==========================================================
Keywords: demonstration, sample, example, demo, Dialog System, itmunsel.zip
demo.ex
demo.ne