Input_SetFocus: It would be great to have it make the cursor appear at end of text.

Input_SetFocus: It would be great to have it make the cursor appear at end of text.

  
Right now, if I use Input_SetFocus widget, if there is text already in the field, it makes the cursor appear in the left (beginning) of text. It would be great to have it mimic the browser behavior to have the cursor appear at the end of the text when you click on that field.

I have researched on ways to make the cursor move to the end, but so far, found either complicated ones or ones that don't work in all browsers.

Anyone have an update on that?

Thanks!
Hi Macro101,

I don't know if I understand what you are trying to do, but to put the cursor at the end of the text (if the input has already text) I found this possible solution:

Add an expression to your screen and set its value to:


"<script type=""text/javascript"">
    $('.focusTextEnd').focus(function(){
        this.selectionStart = this.selectionEnd = this.value.length;
    });
</script>"
 
Don't forget to set the "Escape Content" property of the expression to No and to add the class focusTextEnd to the input widget to focus.


Does it help you?

Cheers,
António Pereira

Yes! ... but very strange...

First I got it to do something different...

It was highlighting the whole text instead of places the cursor at the end - which is an awesome thing to know as well. I will most certainly need that some day.

Here is what it was doing:



So I kept playing with the expression to see if I could make it work. Eventually I put it back the way it was and it is now working perfectly?

Anyway, thank you so much for your solution. Loved it!

(do you know how to make the whole word highlight?)     ;o)