Author: ben
Date: 2007-07-30 14:05:40 -0700 (Mon, 30 Jul 2007)
New Revision: 5856

Modified:
   
openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
   
openlaszlo/branches/wafflecone/test/components/incubator/richtexteditarea-driver.lzx
Log:
Change 20070730-ben-O by [EMAIL PROTECTED] on 2007-07-30 13:44:30 PDT
    in /Users/ben/src/svn/branches/wafflecone
    for http://svn.openlaszlo.org/openlaszlo/branches/wafflecone

Summary: Clean up complicated logic in mouse moved handler in rich text editor

New Features:

Bugs Fixed: LPP-4397 rich text editor: cannot switch to the same font twice

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

Documentation:
Patch by dstowell/jrobey, submitted to openlaszlo for inclusion in
wafflecone. Bug verified and patch reviewed by me, Ben Shine. 
(Referrer code EM-1394)

Release Notes:

Details:

Tests:
http://localhost:8080/wafflecone/test/components/incubator/richtexteditarea-driver.lzx?lzr=swf8
Select the first word and apply Helvetica formatting.
Select the third word and apply Helvetica formatting.
Third word should now be in Helvetica.




Modified: 
openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
===================================================================
--- 
openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
      2007-07-30 20:27:08 UTC (rev 5855)
+++ 
openlaszlo/branches/wafflecone/lps/components/incubator/rich-text/richtexteditarea.lzx
      2007-07-30 21:05:40 UTC (rev 5856)
@@ -4,7 +4,7 @@
   -->
 <library>
     <include href="scrollrichedittext.lzx"/>
-
+    
     <!--- 
     A view which contains the text area for a rich text editor. Combine with a 
     richtexttoolbar to make an actual editor. 
@@ -14,11 +14,15 @@
         <!--- The placement for the toolbar in the richtexteditor. -->
         <attribute name="toolbarplacement" value="null"/>
 
-        <!--- Reference to the toolbar associated with this editor. --> 
-        <attribute name="toolbar" value="$once{parent.parent.toolbar}" />
+        <!--- Reference to the toolbar associated with this editor. 
+            For the toolbar to show the correct format when the insertion
+            point moves, this attribute must be set by users. -->
+        <attribute name="toolbar"  />
         
-        <!--- Reference to the hyperlink creation dialog --> 
-        <attribute name="linkpanel" value="null"/>
+        <!--- Reference to the hyperlink creation dialog.
+            This attribute should be set by users, if there is 
+            an associated link panel --> 
+        <attribute name="linkpanel"/>
         
         <!-- The defaultfontsize, defaultfontname, and defaultfontcolor
              determine the initial configuration of the toolbar, and thus, the
@@ -85,9 +89,7 @@
 
         <!--- @keywords private -->
         <method name="init">
-            // Debug.write("richtexteditor.init"); 
             super.init();
-                        
             // Create a currentformat object, and initialize it to the format
             // specified by the various 
defaultfontsize/defaultfontcolor/defaultfontname
             // attributes. 
@@ -95,17 +97,6 @@
             this._resetFormatToDefaults();
             this.startformat = this.currentformat;
             this.inp.setDefaultFormat(this.currentformat);
-            
-            // I need to force the editor's default to get pushed out to 
-            // any listeners *and* to the actual format of the text field. 
-            // However, my oncurrentformat event hasn't yet been registered. 
-            // So: explicitly push the format to the toolbar
-            this.toolbar.matchformat(this.currentformat);
-            
-            // Point my linkpanel attribute at the linkpanel associated with
-            // this text editor
-            if ("linkpanel" in this.parent.parent) 
-                this.linkpanel = this.parent.parent.linkpanel;
         </method>
 
 <!-- PUBLIC METHODS 
.........................................................-->
@@ -125,7 +116,21 @@
             this._ssel = this._esel = 0;
         ]]></method>
 
+        <!--- Hook this editor up to a toolbar, so that the toolbar's ui
+            will stay synchronized with the format at the insertion point
+            of this editor. --> 
+        <method name="setToolbar" args="tb">            
+            this.toolbar = tb;
+            if (this.isinited) this.toolbar.matchformat(this.currentformat);
+        </method>
+        
+        <!--- Hook this editor up to a link panel, so that the
+            linkpanel will be hidden when the editor is reset -->        
+        <method name="setLinkPanel" args="lp">
+            this.linkpanel = lp;
+        </method>
 
+
 <!-- EVENT HANDLERS 
.........................................................-->
        
         <!--- When a cursor movement key is released, handle the caret motion.
@@ -250,33 +255,22 @@
             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) {
                     
                         // The mouse click started on the richtext editor.
-                        
-                        // 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 {                        
-                            // If the mouseclick ended anywhere but the rich 
text editor,
-                            // it's a lost mousedown. 
-                            this._handleLostMouseDown();                       
+                        // 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();      
                         }
-                    } 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. 
@@ -286,6 +280,7 @@
         
         <!--- 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();
@@ -408,8 +403,7 @@
         --> 
         <method name="_caretmove">
         // Debug.write("caret");
-        // Don't do any of this if this message isn't already rich-text! 
-        // It's *all* just about formatting tweaks. 
+        // Don't do any of this if this field isn't already rich-text! 
         if (!this.isHTML) return; 
 
         //------------------------------------------------------------
@@ -494,8 +488,8 @@
             var havelzfocus =  (LzFocus.getFocus() == this._field); 
             if (havelzfocus) {
                 var len = this.getText().length;
-            // move the insertion point to the beginning of the text
-                this.setSelection(len, len); 
+                // move the insertion point to the beginning of the text
+                this.setSelection(len, len);
                 this._caretmove(); 
             }
         </method>

Modified: 
openlaszlo/branches/wafflecone/test/components/incubator/richtexteditarea-driver.lzx
===================================================================
--- 
openlaszlo/branches/wafflecone/test/components/incubator/richtexteditarea-driver.lzx
        2007-07-30 20:27:08 UTC (rev 5855)
+++ 
openlaszlo/branches/wafflecone/test/components/incubator/richtexteditarea-driver.lzx
        2007-07-30 21:05:40 UTC (rev 5856)
@@ -17,6 +17,7 @@
 <include href="incubator/rich-text/formatfontcolor.lzx"/>
 <include href="incubator/rich-text/formatfontface.lzx"/>
 
+<button y="0">I am button. Tab to me to focus on me.</button>
 <view x="20" y="80" width="${canvas.width-40}" height="${canvas.height-80}">
     <richtexttoolbar name="toolbar" id="gTB" editor="${grte}" height="30" 
width="${parent.width-5}" x="2" y="0" bgcolor="0xD4D7E5">
 
@@ -28,11 +29,11 @@
     </richtexttoolbar>
         
 
-    <view width="100%" y="35" height="${parent.height-70}" bgcolor="0xFFFFFF">
+    <view width="600" y="35" height="${parent.height-70}" bgcolor="0xFFFFFF">
                  <!-- sample text from democracy, an american novel by henry 
adams, 1880 (in public domain) --> 
         <richtexteditarea id="grte" name="txt" 
             height="100%"
-            width="100%"
+            width="500"
             defaultfontname="Verdana" 
             defaultfontsize="18" 
             defaultfontcolor="0x336699"


_______________________________________________
Laszlo-checkins mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-checkins

Reply via email to