Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Eclipse Scout » getConfiguredSelectAllOnFocus() on SmartField
getConfiguredSelectAllOnFocus() on SmartField [message #1699156] Mon, 22 June 2015 08:21 Go to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
AbstractStringField defines getConfiguredSelectAllOnFocus() which can be used to define if the field's content is selected or not when the field gains focus (either using TAB or the mouse).

The same method does not seem to exist on AbstractSmartField and we now have the situation that the previous content of the smartfield (i.e. the text generated by getDataByKey()) ist not selected. This is inconvenient for the user, as he first needs to delete the content before he can enter new search terms.

Is there anyway to make the smartfield pre-select existing content when it gains focus?
Re: getConfiguredSelectAllOnFocus() on SmartField [message #1699158 is a reply to message #1699156] Mon, 22 June 2015 08:23 Go to previous messageGo to next message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
Looking at SwtScoutSmartField.handleSwtFocusGained, it seems that this should already happen, but apparently this doesn't work in our case:

 @Override
  protected void handleSwtFocusGained() {
    super.handleSwtFocusGained();
    if (m_proposalPopup == null) {
      scheduleSelectAll();
    }
    if (getScoutObject().getErrorStatus() != null && getSwtField().getEditable() && getSwtField().isVisible()) {
      requestProposalSupportFromSwt(getScoutObject().getDisplayText(), false);
    }
  }

  @Override
  protected void handleSwtFocusLost() {
    super.handleSwtFocusLost();
    if (!getSwtField().isDisposed()) {
      getSwtField().setSelection(0, 0);
    }
  }

  protected void scheduleSelectAll() {
    getEnvironment().getDisplay().asyncExec(new Runnable() {

      @Override
      public void run() {
        if (getSwtField().isDisposed()) {
          return;
        }

        getSwtField().setSelection(0, getSwtField().getText().length());
      }

    });

  }
Re: getConfiguredSelectAllOnFocus() on SmartField [message #1699159 is a reply to message #1699158] Mon, 22 June 2015 08:30 Go to previous message
Urs Beeli is currently offline Urs BeeliFriend
Messages: 573
Registered: October 2012
Location: Bern, Switzerland
Senior Member
After further investigation, it seems that this actually works reliably for SmartFields that are part of a form. However, when using a SmartField that is created in the execPrepareEdit method of an editable table cell, it sometimes works but most often doesn't. Looking at scheduleSelectAll() I see that in the cases where it doesn't work, getSwtField().getText() returns an empty string, despite the fact that the field displays text.
Previous Topic:Exception when creating new Form
Next Topic:Form based Login - Create User Account on Request
Goto Forum:
  


Current Time: Thu Apr 25 13:52:23 GMT 2024

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

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

Back to the top