Marko Zadravec
Marko Zadravec

Reputation: 8730

Eclipse Scout Neon scroll on position

I have some long form with lots of fields (and boxes). Because of this I would like to have some shortcuts buttons that will scroll to specific groupBox in form.

I try

getMyFieldInBox.requestFocus()

witch works if field is not label or groupBox.

If I try this on groupBox it return me an error :

enter image description here

My problem is that not all group boxes has first "focusable" field.

How to achieve this? I try to override getConfiguredFocusable() in box to true, but is doesn't work.

Upvotes: 0

Views: 93

Answers (3)

Samuel Renold
Samuel Renold

Reputation: 302

From an ergonomic point of view, a scrollable form is to be avoided.

(Historically, forms were not scrollable. Scrollable forms were introduced for special cases, e.g. to cope with low screen resolution on beamers when giving a presentation.)

Ideally, forms should be designed to present the data nicely on the user's screen. This requires that the screen resolution of a user is known.

In general, please try to adapt the following guidelines:

  1. Place the most important information of a form on top.
  2. Information of minor importance should be positioned at the bottom.
  3. Information of even less importance should be positioned in tabs.

Upvotes: 1

Stephan Merkli
Stephan Merkli

Reputation: 161

Requesting the focus on a group box will be fixed with M7. The first focusable field will get the focus. If a group box has no focusable field, no action will be taken when the focus is requested on that group box.

Upvotes: 2

mlu
mlu

Reputation: 91

yes indeed, I was able to reproduce the error by trying to focus a group box (not sure what should be 'focused' on a group box item, but certainly this error should not occur!)! So feel free to open a ticket and report the problem! Maybe we have a common problem when focusing fields where we don't know what to focus (e.g. group boxes & labels, etc.)

Not sure, if I understood your problem correctly, but I suggest (as a workaround), you override requestFocus() in your group box (e.g. main box), where you collect all child fields that are focusable (and maybe of a special type) recursively, sort them by their order and afterwards get the first available one (if one's available) and set focus to that. Else do nothing.

Could be something like that:

    @Override
    public void requestFocus() {
        final Map<Double, IFormField> orderedFields = new TreeMap<>();
        getBoxWithDesiredFocusableFields().visitFields(new IFormFieldVisitor() {

            @Override
            public boolean visitField(IFormField field, int level, int fieldIndex) {
                if (field.isFocusable() && field....some specific conditions) {
                    orderedFields.put(field.getOrder(), field);
                }
                return true;
            }
        }, 0);

        if (orderedFields.keySet().iterator().hasNext()) {
            // Focusable fields available -> get first focusable field
            IFormField firstFocusableField = orderedFields.get(orderedFields.keySet().iterator().next());
            if (firstFocusableField != null) {
                firstFocusableField.getForm().requestFocus(firstFocusableField);
            }
        }
    }

Best regards,

Mattthias

Upvotes: 2

Related Questions