Combo Boxes

From BR Wiki
(Redirected from Combo Box)
Jump to navigation Jump to search

Combo Boxes consist of two parts. A text field with an implied Q attribute, and a drop down list that may be used for selection. The Populate process (with the =, + or -) pertains only to the drop down list. INPUT operations pertain only to the text field and respond just like a text field. If Enter is pressed while entering data, then an Enter action is taken. If the mouse is used to select a NEW value, then the trailing interrupt number (FKey) is applied. However, OPTION 48 may be set on to make Enter act like a mouse double click.

Populate the drop down box:

00100 PRINT FIELDS "row, col,[display-cols/] COMBO data-cols,= [, SELECT] [, Fkey]": mat string$ 	! leading attribute may be =, +,-

Note that, while the SELECT keyword is allowed as a trailing attribute in the following two statements, it has no effect because if SELECT is used, it must be specified when the Combo Box is originally created (when it is populated).

Set the text default field value: (this second step is entirely optional and is often omitted)

00200 PRINT FIELDS "row, col,[display-cols/]  COMBO data-cols,text-attr [, SELECT] [, Fkey]": string$

Input the text field value (upon selection):

00300 INPUT FIELDS "row, col,[display-cols/]  COMBO data-cols, field-input-attr [, SELECT]": string$


Since Combo Boxes are really an enhanced text field, they may be processed with RInput Fields just like any other text field. This would be done by pre-populating them before issuing the Input or RInput Fields that groups them in with other text fields.

Combo Boxes are single column only. Use the Combo drop down character (Q attribute) in conjunction with LIST to effect multi-column dropdowns. Note that such multi-column dropdowns need to be presented in their own child window so they don't destroy underlying controls.

FKey processing for Combo Boxes is significantly different than for use of the Q character. FKey with Combo Boxes has no relation to drop down processing. Instead it triggers the specified FKey event when someone makes a selection with the mouse or by pressing ENTER.

If SELECT is specified (as of Business Rules! version 4.20) when the Combo Box is created it will permit only selection from the drop down list. No text keyboard typing will be permitted. In order to use SELECT, it must be specified when the Combo Box is created by the populate statement. If SELECT is specified for an already existing COMBO control, a BR error is generated.


The following example demonstrates the use of Combo Boxes. Lines 600 and 700 populate two Combo Boxes. On line 800, RINPUT FIELDS groups the two Combo Boxes and inputs the selected car and model into the corresponding variables. Line 900 prints results.


Examples

Example 1
00100 print NEWPAGE
00200 dim CAR$(3)*20,MODEL$(6)*20,SELECTEDCAR$*20,SELECTEDMODEL$*20
00300 let CAR$(1)="BMW": let CAR$(2)="Chrysler": let CAR$(3)="Toyota"
00400 let MODEL$(1)="750 IL": let MODEL$(2)="525 CI": let MODEL$(3)="Sebring"
00500 let MODEL$(4)="Concorde": let MODEL$(5)="Corolla": let MODEL$(6)="Camry"
00600 print fields "1,1,20/combo 20,= ": MAT CAR$
00700 print fields "2,1,20/combo 20,= ": MAT MODEL$
00800 rinput fields "1,1,20/combo 20;2,1,20/combo 20": SELECTEDCAR$,SELECTEDMODEL$
00900 print fields "4,1,C 20;4,21,C 20": SELECTEDCAR$,SELECTEDMODEL$
Output

Output of line 900:

Example 2

This example illustrates the differences between select only and original Combo Boxes.

10800   execute "CON GUI ON"
11000   print newpage
11200   dim option$(1)*32,option_sel$(2)*32
11400   str2mat("One,two,three,four,five",mat option$,',')
11600   print #0,fields "10,10,Cc27,[W]": 'Non Select '
11800   print #0,fields "10,40,Cc27,[W]": 'Select (4.2+)'
12000   print #0,fields "11,10,25/Combo 32,=": mat option$
12200   print #0,fields "11,40,25/Combo 32,=,Select": mat option$
12400   rinput fields "11,10,25/Combo 32,[D]S;11,40,25/Combo 32,[D]S": mat option_sel$
12600   for x=1 to 2 : print 'option_sel$('&str$(x)&')='&option_sel$(x) : next x


Special Notes

Combo Boxes that contain the x attribute often return FKey 209 in such cases use curfld(curfld,fkey) to avoid blinking.

 00010 do
 00020    rinput #win,fields mat io$,attr '[A]': mat setting$,choice_policy$,choice_desc$
 00030    if fkey=209 then let curfld(curfld,fkey)
 00040 loop until fkey<>209