Bug Report B157257
Visible to All Users

ASPxEditors - The client-side SetCaretPosition method doesn't work under Safari

created 15 years ago

Steps to Reproduce:

  1. Put an ASPxEditor (for example, ASPxTextBox) with a mask on a form
  2. Handle the client-side GotFocus of this editor and try to set cursor position using the SetCaretPosition
  3. Run the sample under Safari

Answers approved by DevExpress Support

created 15 years ago (modified 11 years ago)

Hi Mark:
This issue is browser-dependant and specific to webkit browsers. The same problem may be reproduced with a simple input as follows:

JavaScript
function OnFocus() { var inputElement = document.getElementById('testInput'); _aspxSetCaretPosition(inputElement, 0);

The _aspxSetCaretPosition method moves the cursor to a required position, but the browser cancels this action.
A workaround for this problem is to call the _aspxSetCaretPosition method in the 0 timer:

JavaScript
_aspxSetTimeout("_aspxSetCaretPosition(document.getElementById('testInput'))", 0);

NOTE: This trick is necessary when you call the SetCaretPosition from within the controls OnFocus event handler.
Thanks
Kate.

    Comments (1)
    Serge (DevExpress Support) 15 years ago

      Hi Mark,
      I believe we should mention this limitation in our documentation. So, I've created a new suggestion on your behalf: Documentation - ASPxClientTextEdit.SetCaretPosition Method - Highlight the limitations for WebKit browsers
      Thanks,
      Serge

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.