Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » scout » Requesting the focus in a field in a tab box
Requesting the focus in a field in a tab box [message #1294081] Sun, 13 April 2014 05:56 Go to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 765
Registered: October 2011
Senior Member
I am trying to request the focus in Field located in a TabBox.
getMyField().requestFocus()


If the corresponding Tab is not selected, nothing happens.

index.php/fa/17912/0/

Expected:

index.php/fa/17913/0/

Is this the intended behavior?
Do I need to write my own logic to select the tab and request the focus?

Thank you in advance for your feedback.

[Updated on: Sun, 13 April 2014 18:11]

Report message to a moderator

Re: Requesting the focus in a field in a tab box [message #1294696 is a reply to message #1294081] Sun, 13 April 2014 18:25 Go to previous messageGo to next message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 765
Registered: October 2011
Senior Member
The workaround is not so complicated. Here a utility method that does the trick:

public static void activateTabAndRequestFocus(IFormField field) {
  selectTab(field);
  field.requestFocus();
}

/**
 * Recursively set tab as selected in all GroupBoxes to display the field.
 *
 * @param field
 */
private static void selectTab(IFormField field) {
  ICompositeField f = field.getParentField();
  IGroupBox selectedGroupBox = null;
  while (f != null && !(f instanceof ITabBox)) {
    if (f instanceof IGroupBox) {
      selectedGroupBox = (IGroupBox) f;
    }
    f = f.getParentField();
  }
  if (f != null) {
    if (selectedGroupBox != null) {
      ((ITabBox) f).setSelectedTab(selectedGroupBox);
    }
    selectTab(f);
  }
}


The question still remains: is the current Scout behavior (in the framework) the correct one or not.
Re: Requesting the focus in a field in a tab box [message #1319474 is a reply to message #1294696] Mon, 28 April 2014 07:26 Go to previous message
Jeremie Bresson is currently offline Jeremie Bresson
Messages: 765
Registered: October 2011
Senior Member
See also the code:
org.eclipse.scout.rt.client.ui.form.fields.ValidateFormFieldDescriptor.activateProblemLocation()

  @Override
  public void activateProblemLocation() {
    //make sure the table is showing (activate parent tabs)
    IGroupBox g = m_field.getParentGroupBox();
    while (g != null) {
      if (g.getParentField() instanceof ITabBox) {
        ITabBox t = (ITabBox) g.getParentField();
        if (t.getSelectedTab() != g) {
          t.setSelectedTab(g);
        }
      }
      g = g.getParentGroupBox();
    }
    m_field.requestFocus();
  }


I assume it does the same.
Previous Topic:Permissions on Tomcat
Next Topic:How to identify the GUI in use?
Goto Forum:
  


Current Time: Sun Oct 26 06:07:36 GMT 2014

Powered by FUDForum. Page generated in 0.01903 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software