On Fri, Feb 21, 2014 at 8:10 AM, <Amphitryon@ok.de> wrote:

What do I have to change in following dialog to get
i) the selected item displayed in a ComboBox

 scombo = self~newComboBox(IDC_SESCA)
do s over .constDir[GLV_SCLAR]
    scombo~add(s)  -- set allowed scaling factors
  s = '  ' || .constDir[GLV_DISCL]  -- current scale factor
  if s > 9 then s = s + 0  -- remove leading blanks

The select() method will select the first item in the combo box that exactly matches s.

In the above, you add the text s to the combo box.  Then you make some alteration to an s variable and try to select it in the combo box.  If the second s does not exactly match the s actually added to the combo box, nothing will be selected.

A better approach might be to determine the index of the item you want selected and use the selectIndex() method to select the item by index.

However, you logic looks suspect to me.  There is only 1 value for .constDir[GLV_DISCL]  under normal conditions.  Unless you set the .constDir[GLV_DISCL]  to an array, or some other collection, there is no need to use a do over.  Only 1 item will be added to the combo box.

If you did set .constDir[GLV_DISCL]  to an array, then I'd advise against it.  The .constDir is used internally to resolve a symbolic ID, in this case GLV_DISCL, to a single numeric value.  Although there is no law that says you can't use it for your own, other, purpose, I'd worry that you will run into some unintended consequence.

Say your scaling values are: 1, 2, 4, 8, 16, I'd do this:

values = .array~of(1, 2, 4, 8, 16)
do s over values
    scombo~add(s)  -- set allowed scaling factors


or whatever you wanted for the initial selected item.
ii) set the focus on the ComboBox?
(Currently the focus is on the OK button)

The operating system's dialog manager sets the focus to the first dialog control in the dialog template.  So, in defineDialog() add the combo box control to the template first:

 ::method defineDialog unguarded

  self~createComboBoxInput(IDC_SESCA, 5, 20, , 28, , '1/', 'LIST

Mark Miesfeld