Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    DateItem tab-in cursor position

    Hi Isomorphic,

    SmartGWT version: v5.0p_2016-03-19/EnterpriseEdition
    Browser: Safari Version 9.0.2, Chrome 50.0.2661.102 m

    Refer to the Showcase: http://www.smartclient.com/smartgwt/.../#form_masking
    When we Tab from the [Phone No] field into the [Date] field (DateItem with setUseMask=true), and if there is a value in the [Date] field, currently the cursor position will always go to the end of the date, May I know is there any way to allocate the cursor in front of the date?

    Click image for larger version

Name:	DateItem.JPG
Views:	51
Size:	43.7 KB
ID:	238167

    for previous build (v5.0p_2015-05-15/EnterpriseEdition), the cursor position is default to be in front of the date when we tab-into the DateItem field with mask. After update the version to v5.0p_2016-03-19/EnterpriseEdition, the cursor change to be back of the date.

    I did try the following but no luck too:

    1) deselectValue: start - By default the text insertion cursor will be moved to the end of the current value - pass in this parameter to move to the start instead

    Coding: ( i tried both of focus and editor enter event)
    DateItem dateField = new DateItem("dateItem", "Date");
    dateField.setUseTextField(true);
    dateField.setUseMask(true); dateField.addFocusHandler(new FocusHandler(){
    @Override
    public void onFocus(FocusEvent event) {
    dateField.deselectValue(true);
    }
    });

    dateField.addEditorEnterHandler(new EditorEnterHandler(){
    @Override
    public void onEditorEnter(EditorEnterEvent event) {
    dateField.deselectValue(true);
    }
    });

    2) setSelectionRange

    Coding: ( i tried both of focus and editor enter event)
    DateItem dateField = new DateItem("dateItem", "Date");
    dateField.setUseTextField(true);
    dateField.setUseMask(true); dateField.addFocusHandler(new FocusHandler(){
    @Override
    public void onFocus(FocusEvent event) {
    dateField.setSelectionRange(0,1);
    }
    });

    dateField.addEditorEnterHandler(new EditorEnterHandler(){
    @Override
    public void onEditorEnter(EditorEnterEvent event) {
    dateField.setSelectionRange(0,1);
    }
    });

    3)
    Coding: (tried to see whether can default select the whole date)
    DateItem dateField = new DateItem("dateItem", "Date");
    dateField.setUseTextField(true);
    dateField.setUseMask(true);
    dateField.setSelectOnClick(true);
    dateField.setSelectOnFocus(true);
    Thanks & Best Regards.

    #2
    We agree that the default behavior of putting focus at the end of a completed, masked text-entry box (whether in a Date field or not) is not ideal.
    We've made a change to instead put focus onto the start of the item when the mask is "full". This will be present in the next nightly build, dated June 8 or above.
    We've applied the change all the way back to the 5.0 branch.

    If you wanted to use selectOnFocus by the way, you would need to use the "setTextFieldProperties()" method on the DateItem so you set this property on the embedded TextItem auto-child. However you'll also need the new nightly build to make that work (there was a related, but separate behavior change required to ensure this works as expected, which we made at the same time).

    Regards
    Isomorphic Software

    Comment

    Working...
    X