Reviewers: jgw, Description: Description: =========== In Firefox, the text caret always appears at the begining of the RichTextArea when the user clicks the first time, regardless of where in the RichTextArea the user clicked.
The problem is that we set design mode on focus in Mozilla, which occurs after the caret is moved. As a result, the caret isn't set because the RichTextArea isn't editable yet. Fix: === We now switch to design mode onfocus or onmouseover. By switching onmouseover, we can ensure that we are in design mode before the user selects a caret position. We still need the onfocus because the user might tab into the RichTextArea, in which case its perfectly acceptable to default to the 0th position in the text. Testing: ======== Manually verified this fix on FF1.5, FF2.0, and FF3.0. Please review this at http://gwt-code-reviews.appspot.com/50802 Affected files: user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java Index: user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java =================================================================== --- user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java (revision 5635) +++ user/src/com/google/gwt/user/client/ui/impl/RichTextAreaImplMozilla.java (working copy) @@ -36,16 +36,28 @@ // Send notification that the iframe has finished loading. _th...@com.google.gwt.user.client.ui.impl.richtextareaimplstandard::onElementInitialized()(); - // Don't set designMode until the RTA actually gets focused. This is + // Don't set designMode until the RTA is targeted by an event. This is // necessary because editing won't work on Mozilla if the iframe is - // *hidden, but attached*. Waiting for focus gets around this issue. + // *hidden, but attached*. Waiting for an event gets around this issue. // - // Note: This onfocus will not conflict with the addEventListener('focus', - // ...) // in RichTextAreaImplStandard. + // Note: These events will not conflict with the + // addEventListener('oneventtype', ...) in RichTextAreaImplStandard. iframe.contentWindow.onfocus = function() { iframe.contentWindow.onfocus = null; + iframe.contentWindow.onmouseover = null; iframe.contentWindow.document.designMode = 'On'; }; + + // Issue 1441: we also need to catch the onmouseover event because focus + // occurs after mouse down, so the cursor will not appear until the user + // clicks twice, making the RichTextArea look uneditable. Catching the + // mouseover event allows us to set design mode earlier. The focus event + // is still needed to handle tab selection. + iframe.contentWindow.onmouseover = function() { + iframe.contentWindow.onfocus = null; + iframe.contentWindow.onmouseover = null; + iframe.contentWindow.document.designMode = 'On'; + }; }; }-*/; --~--~---------~--~----~------------~-------~--~----~ http://groups.google.com/group/Google-Web-Toolkit-Contributors -~----------~----~----~----~------~----~------~--~---
