Quantcast
Channel: SmartClient Forums
Viewing all articles
Browse latest Browse all 4756

IE8 bug for TextAreaItem.getSelectionRange()

$
0
0
IE 8 only bug (all the rest work as expected) for gwt 3.1.
I believe the IE8 lost the "\r\n" during counting.

Here's the code, which I created to demonstrate the bug:
Code:


DynamicForm form = new DynamicForm();
       
        final TextAreaItem txt = new TextAreaItem("test");
        txt.setValue("1\r\n2\r\n3\r\n4\r\n5\r\n6\r\n7\r\n8\r\n9\r\n10\r\n11");
        txt.addClickHandler( new com.smartgwt.client.widgets.form.fields.events.ClickHandler(){

               
                        @Override
                        public void onClick(com.smartgwt.client.widgets.form.fields.events.ClickEvent event) {
                                Object source = event.getSource();
                                if(source instanceof TextAreaItem) {
                                        TextAreaItem text = (TextAreaItem)source;
                                        int range[] = text.getSelectionRange();
                                        SC.say("Txt Range is " + range[0] + ":" + range[1]);
                                        String str = (String)text.getValue();
                                        str = str.substring(0, range[0]) + "A" + str.substring(range[1]);
                                        text.setValue(str);
                                       
                                }
                        }
               
        });
       
        form.setFields(txt);

In all browsers this code prints "A" on the place you clicked inside the TextAreaitem. In IE8 it somehow loses "\r\n" - all of them in front of your click. For example if you click after "7" - the "A" is inserted after "5".

Viewing all articles
Browse latest Browse all 4756

Trending Articles