Looks like we can't reproduce the issue or there's a problem in the test case provided.
  1. #1
    Sencha User
    Join Date
    Mar 2012
    Posts
    87
    Vote Rating
    3
    esag_dk is on a distinguished road

      0  

    Default SetSelectionRange doesn't work

    SetSelectionRange doesn't work


    Hello,

    it's not possible to set the selection of a ValueBaseField (GXT 3.0.1, Firefox 10.0.6/Internet Explorer 9).
    So here's an example:

    Code:
    public class GXT_3_0 implements EntryPoint {
    
        public void onModuleLoad() {
            RootPanel.get().add(createMainPanel());
        }
    
        private Container createMainPanel() {
            VerticalLayoutContainer vlc = new VerticalLayoutContainer();
            vlc.setBorders(true);
            vlc.setPixelSize(600, 400);
    
            final TextField field = new TextField() {
                // {
                // impl = GWT.create(MooTextBoxImpl.class);
                // }
            };
            field.setValue("test string");
    
            vlc.add(field);
    
            final TextButton button = new TextButton("clickMe");
            button.addSelectHandler(new SelectHandler() {
    
                @Override
                public void onSelect(SelectEvent event) {
                    field.focus();
                    field.setSelectionRange(2, 5);
                }
            });
            vlc.add(button);
    
            return vlc;
        }
    }
    In Firefox the selection doesn't change at all, in Internet Explorer the cursor is beeing moved to the first position.
    This happens because you're calling the javascript method 'setSelectionRange' on a div container and not the input element itself as it is intended:
    https://developer.mozilla.org/en-US/...SelectionRange

    Try my commented out code and add MooTextBoxImpl:

    Code:
    public class MooTextBoxImpl extends TextBoxImpl {
    
        public MooTextBoxImpl() {
    
        }
    
        public native void setSelectionRange(Element elem, int pos, int length) /*-{
            window.alert(elem.id); // x-widget-1, which is the grandparent node of the actual input element
            //        elem = elem.firstChild.firstChild; // this 'fix' works just fine
            try {
                elem.setSelectionRange(pos, pos + length);
            } catch (e) {
                window.alert(e); // let's show the exception here
            }
        }-*/;
    }
    The first message returns "x-widget-1", the grandparent of the input element. The second message returns the following exception: "TypeError: elem.setSelectionRange is not a function".

    If you add my commented out line, everything works just fine. It's not really a fix, but it shows you where the problem lies. Hopefully you can fix this one soon.

  2. #2
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    TextBoxImpl is the specific code run for each browser - if there is a bug, it is in the GXT classes that try to use it, and how they are invoking it.

    In this case, ValueBaseField has a bug - in its setSelectionRange(int,int) method, it should be passing getInputEl() into impl.setSelectionRange, not getElement(). A fix for this was committed on Nov 2nd, and appears to be present in 3.0.3. Can you confirm that this works in 3.0.3?

    Your fix may work as a workaround, but is a little sketchy, as this may break other classes like the GWT TextBox or TextArea. Another idea could be to do your try/catch, but in the catch, reassign elem to elem.firstChild.firstChild, and try again. This, by the way, is what getInputEl() does - it asks the cell to get the input element, the cell asks the appearance, and the appearance invokes parent.getFirstChildElement().getFirstChildElement().

  3. #3
    Sencha User
    Join Date
    Mar 2012
    Posts
    87
    Vote Rating
    3
    esag_dk is on a distinguished road

      0  

    Default


    Quote Originally Posted by Colin Alworth View Post
    Your fix may work as a workaround, but is a little sketchy, as this may break other classes like the GWT TextBox or TextArea.
    Yeah, as I wrote it is a really dirty fix. For now I'm using my TextBoxImpl implementation only for one TextField subclass, so it won't break anything else.


    Quote Originally Posted by Colin Alworth View Post
    A fix for this was committed on Nov 2nd, and appears to be present in 3.0.3. Can you confirm that this works in 3.0.3?
    Wow, that sound's great! How can I access the 3.0.3 version? I can't even access the 3.0.2 release (do I have a "Sencha support subscription" as a "Sencha premium member"? My login data doesn't seem to work there..). I would be grateful for a short message.

  4. #4
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Vote Rating
    80
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    You've got the "Sencha Premium Member" tag under your name, so I assume that you've got access to https://support.sencha.com/ - nightly builds and support releases are available there as well as support tickets. If you don't have access to that, send an email to your sales person, or send me an email at colin.alworth@sencha.com.

  5. #5
    Sencha User
    Join Date
    Mar 2012
    Posts
    87
    Vote Rating
    3
    esag_dk is on a distinguished road

      0  

    Default


    Now I could log in successfully, thanks!
    I will update this bug report after testing 3.0.3.

  6. #6
    Sencha User
    Join Date
    Mar 2012
    Posts
    87
    Vote Rating
    3
    esag_dk is on a distinguished road

      0  

    Default


    It's fixed in 3.0.3, thanks!

Thread Participants: 1

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar