[Laszlo-checkins] r5985 - in openlaszlo/branches/wafflecone/lps/components/incubator/rich-text: . test

ben@openlaszlo.org ben at openlaszlo.org
Thu Aug 9 13:19:55 PDT 2007


Author: ben
Date: 2007-08-09 13:19:51 -0700 (Thu, 09 Aug 2007)
New Revision: 5985

Modified:
   openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/formatfontcolor.lzx
   openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
   openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/test/linkdialog-test.lzx
Log:
Change 20070808-ben-z by ben at slim.local on 2007-08-08 17:24:47 PDT
    in /Users/ben/src/svn/openlaszlo/branches/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Cleanup of insertion point movement in rich text editor

New Features:

Bugs Fixed: LPP-4396 rich text editor: clicking bold moves insertion point

Technical Reviewer: max 
QA Reviewer: mamye (pending)
Doc Reviewer: (pending)

Documentation:

Using the fix for LPP-4015 (Text selection position and size should be available during onblur event) I sanitized the rich text editor's saving and restoring of the selected region. 

There is a new bug introduced with this checkin: LPP-4461: In rich text editor, font color combo box does not update when cursor moves to different colored text. I am tracking this down. 

Release Notes:

Details:

richtexteditarea.lzx -- The big change here was in the onblur method. Now that LPP-4015 has been fixed, we can store the correct selection range whenever we're about to lose focus. I also undid a change suggested by an external contributor, because it was causing problems in the new world, perhaps because it was incompatible with the platform/wafflecone rich text editor. 

linkdialog-test.lzx  -- very explicitly created connections between the link dialog and the editor. 

formatfontcolor.lzx -- moved dataset describing color choices out of a state. This will slow startup a little bit, but the whole thing doesn't work if the color choices are in a state. (This state/dataset behavior interaction filed as LPP-4469 for investigation.)

Tests:
Interactive test available here: 
http://localhost:8080/wafflecone/lps/components/incubator/rich-text/test/richtexteditarea-test.lzx?debug=true&lzr=swf8

lzunit tests here: 
http://localhost:8080/wafflecone/lps/components/incubator/rich-text/test/linkdialog-test.lzx?debug=true&lzr=swf8
http://localhost:8080/wafflecone/lps/components/incubator/rich-text/test/scrollrichedittext-test.lzx?debug=true&lzr=swf8
http://localhost:8080/wafflecone/lps/components/incubator/rich-text/test/richtexteditor-test.lzx?lzr=swf8&debug=true
http://localhost:8080/wafflecone/lps/components/incubator/rich-text/test/richtexteditarea-test.lzx?debug=true&lzr=swf8



Modified: openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/formatfontcolor.lzx
===================================================================
--- openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/formatfontcolor.lzx	2007-08-09 18:54:34 UTC (rev 5984)
+++ openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/formatfontcolor.lzx	2007-08-09 20:19:51 UTC (rev 5985)
@@ -10,7 +10,6 @@
      <!-- Data: Font Color
          inside of a state because datasets get instantiated upon application init
          the state delays instantiation until the RTE is used. -->
-     <state name="fontColorData">
      <dataset name="fontcolors">
          <clr value="0x000000"/>
          <clr value="0x555555"/>
@@ -21,7 +20,6 @@
          <clr value="0xcc9933"/>
          <clr value="0xcc3300"/>
      </dataset>
-     </state>
      <!--- 
          A class which is used as a combobox item
      -->    
@@ -54,7 +52,6 @@
              apply state for late instantiation of local data -->
          <method name="construct" args="parent, args">
              super.construct(parent, args);
-             fontColorData.apply();
          </method>    
          <!--- When the user selects an item from the combo box, 
              create an object representing just the change in format.

Modified: openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
===================================================================
--- openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx	2007-08-09 18:54:34 UTC (rev 5984)
+++ openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx	2007-08-09 20:19:51 UTC (rev 5985)
@@ -209,17 +209,11 @@
             @param view s: the view which is gaining the selection
         -->
         <method event="onblur" args="s">
+            var start = this._field.getSelectionPosition();
+            var size = this._field.getSelectionSize();
+            this._ssel = start;
+            this._esel = start + size;          
             this._fieldhasfocus = false; 
-            // If we're blurring and the focus is going to anything *but* the toolbar
-            // widgets, set _ssel and _esel to nothing. 
-            // Semantically, we want to get rid of the selection if we lose focus. 
-            if (s != null) {
-                // We're really giving focus to something else, so, forget 
-                // about whatever was selected while this component still had focus.
-                // It seems to "feel" right to me to move the cursor to the end of 
-                // the text. 
-                this._ssel = this._esel = this.getText().length;
-            }
         </method>
         
         
@@ -251,44 +245,56 @@
             is there a mousedown/mouseup pair in progress? 
             @param view who: the current mousedown element (ben shine)
         -->
-        <method event="onmouseup" reference="LzGlobalMouse" args="who">
+       <method event="onmouseup" reference="LzGlobalMouse" args="who"><![CDATA[
             if (this._fieldhasfocus) {
                 // Debug.write("onmouseup, field has focus, who is ", who); 
 
-                // [bshine 07.28.2007] the next block is a new patch from diamond   
-                this._caretmove(); 
                 if (this._mousedownorigin != null) {
                     // We have focus, and there _is_ a mousedown/mouseup pair in progress. 
-                    if (this._mousedownorigin == this) {
+                    if (this._mousedownorigin == this || this._mousedownorigin == this.inp) {
                     
                         // The mouse click started on the richtext editor.
-                        // If the mouse click didn't end on the rich text editor, 
-                        // handle that.
-                        if (!inp.containsPt(this.getMouse("x"), this.getMouse("y"))) {                        
-                            this._handleLostMouseDown();      
+                        
+                        // If the mouse click also ended on the rich text editor, 
+                        // it's just a caret move. 
+                        if (inp.containsPt(this.getMouse("x"), this.getMouse("y"))) {
+                            this._caretmove(); 
+                        } else {  
+                            // Debug.write("handleLostMouseDown"); 
+                            // If the mouseclick ended anywhere but the rich text editor,
+                            // it's a lost mousedown. 
+                            this._handleLostMouseDown();                       
                         }
-                    }
+                    } else {
+                        // We have focus, and there's a mousedown/mouseup pair in progress,
+                        // and it started on one of the subviews of the RTE. 
+                        // Debug.write("lost mousedown, origin was ", this._mousedownorigin); 
+                    } 
+
+                } else {
+                    // We have focus, but there's no mousedown/mouseup pair in progress.
+                    // Therefore, do nothing.                     
+                    // Debug.write("No mousedown origin. The mousedown didn't start on an RTE component."); 
                 }
             }
-                        
 
             // Clear the mousedown attribute; a mouseup means that whatever
             // the mousedown was, it's gone now. 
             this._mousedownorigin = null;          
-        </method>
+        ]]></method>
         
         
         <!--- Save selected region. -->
         <method name="saveSelectionRegion"><![CDATA[  
-            // [bshine 07.28.2007] See LPP-4015. Does this need to change now that LPP-4015 has been changed?
             if (LzFocus.getFocus() == this._field) {
                 var selpos  = this._field.getSelectionPosition();
                 var selsize = this._field.getSelectionSize();
                 if( selpos >= 0 && selsize >= 0){  
                     this.setAttribute('_ssel', selpos);
                     this.setAttribute('_esel', selpos + selsize );
+                    // Debug.write("fascinating, storing selection of %d-%d", this._ssel, this._esel); 
                 }
-            }
+            } 
             ]]>
        </method>
         
@@ -373,7 +379,6 @@
             if (! this['_selectiondel']) {
                 this._selectiondel = new LzDelegate(this, '_restoreSelection');
             }            
-            
             // After the formatting has been completed, need to wait a frame to
             // restore the selection.
             LzIdle.callOnIdle(this._selectiondel);       
@@ -385,7 +390,6 @@
             if (! this['_focusseldel']) {
                 this._focusseldel = new LzDelegate(this, '_focussel');
             }
-            
             LzIdle.callOnIdle(this._focusseldel);  
         </method>
         
@@ -402,7 +406,6 @@
               @access private
         --> 
         <method name="_caretmove">
-        // Debug.write("caret");
         // Don't do any of this if this field isn't already rich-text! 
         if (!this.isHTML) return; 
 
@@ -418,7 +421,6 @@
         // mouseout then mouseup not over richinputtext. 
         //------------------------------------------------------------
         
-        
         var selstart = this._field.getSelectionPosition();
         var sellen = this._field.getSelectionSize();
         var text = this.getText();
@@ -535,6 +537,7 @@
             this._shouldresettoolbar = false; 
             this.setSelection(this._ssel, this._esel);
             this._shouldresettoolbar = true; 
+
         </method>
         
         <!--- Helper method to set an textformat to its default for this

Modified: openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/test/linkdialog-test.lzx
===================================================================
--- openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/test/linkdialog-test.lzx	2007-08-09 18:54:34 UTC (rev 5984)
+++ openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/test/linkdialog-test.lzx	2007-08-09 20:19:51 UTC (rev 5985)
@@ -18,7 +18,7 @@
 
 <view x="20" y="80" width="${canvas.width-40}" height="${canvas.height-80}">
     <!-- A very boring toolbar which only contains a link button --> 
-    <richtexttoolbar name="toolbar" editor="${grte}" height="30" width="${parent.width-5}" x="2" y="0" bgcolor="0xD4D7E5">
+    <richtexttoolbar name="toolbar" height="30" width="${parent.width-5}" x="2" y="0" bgcolor="0xD4D7E5">
         <formatbtn name="linkbtn" id="linkbtn" format="link" iconname="link" icony="3" y="2">
         link
             <method name="doClick">
@@ -42,6 +42,7 @@
             border="10"  text="For reasons which many persons thought ridiculous, Mrs. Lightfoot Lee decided to pass the winter in Washington. She was in excellent health, but she said that the climate would do her good. In New York she had troops of friends, but she suddenly became eager to see again the very small number of those who lived on the Potomac. It was only to her closest intimates that she honestly acknowledged herself to be tortured by ennui. Since her husband's death, five years before, she had lost her taste for New York society; she had felt no interest in the price of stocks, and very little in the men who dealt in them; she had become serious. What was it all worth, this wilderness of men and women as monotonous as the brown stone houses they lived in? In her despair she had resorted to desperate measures. She had read philosophy in the original German, and the more she read, the more she was disheartened that so much culture should lead to nothing... nothing.">
             <method event="oninit">
                 this.setLinkPanel(ldlg);
+                linkbtn.setAttribute("editor", this); 
             </method>
             
         </richtexteditarea>
@@ -75,6 +76,7 @@
             assertFalse(fmt.url == "http://del.icio.us"); 
         </method>
         <method name="testShowingLinkDialog"><![CDATA[
+            Debug.write("linkbtn is... %w and linkbtn.editor is %w", linkbtn, linkbtn.editor); 
             linkbtn.doClick();
             Debug.write("height: ", ldlg.height); 
             assertTrue(ldlg.height > 0); 



More information about the Laszlo-checkins mailing list