Combo Boxes

From BR Wiki
Revision as of 02:23, 22 February 2014 by Gabriel (talk | contribs)
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.

Populate the drop down box:

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

Set the text field value:

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 ComboBoxes 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 ComboBox 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 comboboxes.

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

FKEY(<value>)

See also FKEY (Disambiguation)

The FKey internal function is similar to CmdKey, but returns more information, particularly about how a field is exited. A HotKey is very similar to either of these, but is different in that hotkey is not a control word, statement, nor internal function. HotKey is simply a term that refers to an assigned FKey value. Hot key (Fkey) values can be assigned via a print fields or input fields statement that makes a control clickable. Fkey values can also be assigned to entire windows to make the window trigger an interrupt when it is clicked.

Additionally, when an Input Field is assigned an Fkey value and Enter is pressed while the cursor is in that field, or the field is double clicked, then that fkey number is assigned to the internal FKEY variable and, if that value is preset to take action, then that interrupt occurs. OPTION 48 causes BR to disregard Fkey value assignments when Enter is pressed (FKEY is set to zero).

The following table shows a comparison of the values that are returned by FKey and CmdKey when a particular key is pressed to terminate field input. Fkey values above 100 do not cause INPUT FIELDS to terminate processing, but when control is returned to a program for other reasons the FKEY internal function can be used to determine what was keyed.

FKey(X) sets the value of FKey to X. It also sets the value of CmdKey. However, if X is greater than 91 then CmdKey is set to zero. Likewise, the function CmdKey(X) sets both CmdKey and FKey to the value of X.

Keyboard Mapping for FKeys

Key Shifted FKey Interrupt (qwerty) Control Details
Plain Shifted Alt
a A 30 0
b B 48 90
c C 46
d D 32
e E 18 113
f F 33 91
g G 34 111
h H 35
i I 23 110
j J 36 104
k K 37 102
l L 38 116
m M 50 0
n N 49 103
o O 24 115
p P 25
q Q 16
r R 19 105
s S 31
t T 20 106
u U 22 114
v V 47
w W 17 112
x X 45
y Y 21 100
z Z 44
1 !
2 @ 121
3 # 122
4 $ 123
5 % 124
6 ^ 125
7 & 126
8 * 127
9 ( 128
0 ) 129
` ~
- _ 130
= +
[ { 99
] }
\
; :
' "
, <
. >
/ ?
tab 110 111
field+ 114
field- 115

Note that BR retains select (hilite) status while shift or control remain depressed after a program receives control in navigation mode. When in edit mode, the control key temporarily switches to navigation mode.

*In the following chart, the asterisks denotes a change that occurred with version 4.3. Most of the keys in prior versions were unassigned, but a few were assigned differently.

Key Shifted FKey Interrupt (qwerty) Control Details
Plain Shifted Alt
enter 0 0 0 0
home 112 112* 112 112
end 113 113* 113 113
pageUp 90 90 90 90
pageDn 91 91 91 91
up-arrow 102 102* 102 102* FIELDS
down-arrow 104 104* 104 104* FIELDS
left arrow 103 103* 103 103* FIELDS
right arrow 116 116* 116 116* FIELDS
up-arrow 105 105 105* 105* SELECT
down-arrow 106 106 106* 106* SELECT
left arrow 108 108 108* 108* SELECT
right arrow 109 109 109* 109* SELECT
left click 200
second left 201
right click 100
second right 101
wheel up 124
wheel down 125
F1 1 11 1 21
F2 2 12 2 22
F3 3 13 3 23
F4 4 14 93 24
F5 5 15 5 25
F6 6 16 6 26
F7 7 17 7 27
F8 8 18 8 28
F9 9 19 9 29
F10 10 20 10 30
F11 11 21 11 31
F12 12 22 12 32

Standard FKeys

FKey value Cause Additional
1 F1
2 F2
3 F3
4 F4
5 F5
6 F6
7 F7
8 F8
9 F9
10 F10
11 F11 or Shift+F1
12 F12 or Shift+F2
13 Shift+F3
14 Shift+F4
15 Shift+F5
16 Shift+F6 or Alt+Q
17 Shift+F7 or Alt+W
18 Shift+F8 or Alt+E
19 Shift+F9 or Alt+R
20 Shift+F10 or Alt+T
21 Ctrl+F1 or Alt+Y
22 Ctrl+F2 or Alt+U
23 Ctrl+F3 or Alt+I
24 Ctrl+F4 or Alt+O
25 Ctrl+F5 or Alt+P
26 Ctrl+F6
27 Ctrl+F7
28 Ctrl+F8
29 Ctrl+F9
30 Ctrl+F10 or Alt+A *
31 Ctrl+F11 or Alt+S *
32 Ctrl+F12 or Alt+D *
33 Alt+F *
34 Alt+G *
35 Alt+H *
36
37 Alt+K *
38 Alt+L *
39
40
41
44 Alt+Z *
45 Alt+X *
46 Alt+C *
47 Alt+V *
48 Alt+B *
49 Alt+N *
50 Alt+M *
90 page up
91 page down
92 tab change
93 Application Exit, Alt+F4 or Big X An Option exist to reassign this to a different value
98 Drop Down Menu ??
99 Escape or Alt+J *
100 Ctrl+Y
104 AE field exit
105 AE field exit
106 AE field exit
107 AE field exit
110 AE field exit (Tab)
200 click
201 Double Click (Requires Option (config) 52)
* Alt+Key combinations will not work if a drop down menu co-exists with that letter specified as hot (with a &) at any level of the menu.


FKey 200 and FKey 206 are similar. On windows machines with single click enabled a 200 will be returned instead of a 206.

From a GRID with AEX attributes

These have been tested and should probably be added to the the chart above.

FKey value Cause Additional
91 Ctrl+Left
110 Tab
111 Shift+Tab
112 Home
113 End
114 Field Plus (+) (the Plus key on the number pad)
116 Right
120 Ctrl+End or Shift+End
126 Ctrl+Up
127 Ctrl+Down
133 Shift+Left
134 Shift+Right
135 Shift+Up
136 Shift+Down
200 Double Click (sometimes - also 201) Also Click on windows machines with the single click preference enabled.
201 Double Click (sometimes - also 200) (Requires Option (config) 52)
206 Click

From a GRID with LX attributes

FKey value Cause Additional
124 Mouse Wheel scroll up
125 Mouse Wheel scroll down

From a TextBox with AEX attributes

These have been tested and should probably be added the the chart above. FKey values listed in the GRID with AEX section above are not duplicated here.

FKey value Cause Additional
102 Up
103 Left (from leftmost position)
104 Down

From a GRID with L attributes

FKey value Cause Additional
105 Attempt to Scroll past top
106 Attempt to Scroll past bottom

KStat Only

The KSTAT$ internal function will return a few additional FKey values which Input Fields and Input Select will not. These FKeys are as follows:

FKey Description
176 Click
177 Second Click in Double Click
180 Right Click
181 Second Click in Double Right Click

Combobox Only

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

Hot Windows

For versions 4.2 and higher FKEY= may now be specified in an Open Window statement. This makes the window hot, so a user can click anywhere in the window to tell the program that they want to switch focus. The FKEY value is then inheritable, but not to independent windows. In other words, assigning an FKEY value to a window automatically assigns the same FKEY value to it's child windows, unless another FKEY ( or -1 ) is assigned to a child.