Consultor Eletrônico



Kbase 13355: How to create a COMBO BOX in Version 7
Autor   Progress Software Corporation - Progress
Acesso   Público
Publicação   5/10/1998
How to create a COMBO BOX in Version 7


This document discusses some ideas for creating a COMBO BOX in Version
7 Progress. It should be noted that beginning with Version 7.3,
there is an actual COMBO-BOX widget. Users may still wish to create
customized combo-boxes due to the wish to incorporate different
widget behaviors.

What is a combo box? It is a fill-in widget with a button next to it:

.--------------.+--+
FILL-1: | || | <-- BUTTON-1
`--------------'+--+


Typically, the button has an image on it showing a "down-arrow."
This provides a visual cue to the user to click on the button.
When the button is chosen, a selection list appears immediately
below the fill-in, giving a set of possible values for the fill-in:

.--------------.+--+
FILL-1: | || | <-- BUTTON-1
`--------------'+--+
| Red |
| Green | <-- SELECT-1
| Blue |
| Orange |
| Yellow |
| Violet |
`--------------'

When the user clicks on one of the selected values, it automatically
appears in the fill-in as well:

.--------------.+--+
FILL-1: | Blue || | <-- BUTTON-1
`--------------'+--+
| Red |
| Green | <-- SELECT-1
| Blue |
| Orange |
| Yellow |
| Violet |
`--------------'


At this point, the selection list part of the combo box usually
disappears and the fill-in retains it's new value. The programmer
may or may not decide to code the combo box such that *only* the
selection list values can be legally entered.

To create your own combo box, you'll need a fill-in, a button, and
a selection list. Create them so that they are configured as in the
diagrams above. Key aspects of functionality should then be added
to your code:

(1) The SELECTION LIST should be hidden at the start of your
program. This can be done using the :VISIBLE attribute:

ASSIGN SELECT-1:VISIBLE = NO.

Be sure to ENABLE the SELECTION LIST along with the other
widgets in your interface.


(2) The ON CHOOSE trigger for the BUTTON should be programmed to
make the selection list visible. This again can be done using
the :VISIBLE attribute:

ON CHOOSE OF BUTTON-1 IN FRAME f DO:
IF SELECT-1:VISIBLE THEN ASSIGN SELECT-1:VISIBLE = NO.
ELSE SELECT-1:VISIBLE = YES.
END.


(3) The BUTTON should have a down-arrow image rather than text label.
Progress provides a suitable image file in the DLC area.

On the MS-Windows platform, the file name is:

%DLC%\GUI\ADEICON\Y-COMBO.BMP

On Motif, the file name is:

$DLC/GUI/ADEICON/Y-COMBO.XPM


(4) The VALUE-CHANGED trigger for the SELECTION LIST should be coded
to place the chosen list-item into the FILL-IN. You might also
want to hide the SELECTION LIST after the selection is made:

ON VALUE-CHANGED OF SELECT-1 IN FRAME f DO:
FILL-1:SCREEN-VALUE = SELECT-1:SCREEN-VALUE.
SELECT-1:VISIBLE = NO.
END.


(5) Since :SCREEN-VALUE data exists only in "screenland," we
recommend that you also include an "Okay", "Save", or "Assign"
button on your interface. The ON CHOOSE trigger code for this
button should actually assign the fill-in to equal its
:SCREEN-VALUE with either of the following:

ON CHOOSE OF b_Save IN FRAME f DO:
ASSIGN FILL-1.
END.

< or >

ON CHOOSE OF b_Save IN FRAME f DO:
ASSIGN FILL-1 = FILL-1:SCREEN-VALUE.
END.

(Note that the ASSIGN used in the first case is shorthand for
the more "spelled-out" second version.)

Progress Software Technical Support Note # 13355