[Laszlo-checkins] r8424 - openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf

hqm@openlaszlo.org hqm at openlaszlo.org
Wed Mar 26 08:01:56 PDT 2008


Author: hqm
Date: 2008-03-26 08:01:54 -0700 (Wed, 26 Mar 2008)
New Revision: 8424

Modified:
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
   openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
Log:
Change 20080326-hqm-F by hqm at badtzmaru.local on 2008-03-26 10:42:53 EDT
    in /Users/hqm/openlaszlo/trunk4/WEB-INF/lps/lfc
    for http://svn.openlaszlo.org/openlaszlo/trunk/WEB-INF/lps/lfc

Summary: fix for context-menu bug on views with image resource

New Features:

Bugs Fixed: LPP-5636, LPP-5670

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

Documentation:

Release Notes:

Details:

+ Made setContextMenu set the menu on the foreground movieclip if
there is one
+ Made setResource copy the previous resource movieclip's menu to the
new resource movieclip.
  If there was not a menu property on the foreground movieclip, try
copying the menu property from the
  background-color movieclip.




Tests:

test case from bug report, right click over image area shows same menu
as over background area.

I used this test case, placed in the test/ directory, so as to access
the resource in
test/resources/gif/logo.gif


<canvas>
    <view width="300" height="100" bgcolor="blue" resource="resources/gif/logo.gif">
        <handler name="oninit">
                var cm = new LzContextMenu();
                cm.addItem(cm.makeMenuItem('new item 1'));
                cm.addItem(cm.makeMenuItem('new item 2'));
                setContextMenu(cm);
        </handler>
        <handler name="onclick">
          this.setSource("resources/png/face.png");
        </handler>
        
    </view>
</canvas>

Click right on image and background areas to verify that image and background have custom context menu
Click left on view to load new resource
Click right on image and background areas to verify that image and background have the custom context menu





Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as	2008-03-26 14:45:31 UTC (rev 8423)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzMakeLoadSprite.as	2008-03-26 15:01:54 UTC (rev 8424)
@@ -197,6 +197,11 @@
     this.setHeight(this.hassetheight?this.height:null);
     this.setWidth(this.hassetwidth?this.width:null);
 
+    if (this.__contextmenu) {
+        this.setContextMenu(this.__contextmenu);
+    }
+
+
     this.owner.__LZvizLoad = true; 
     this.owner.__LZupdateShown();
     this.owner.resourceload({width: this.resourcewidth, height: this.resourceheight, resource: this.resource, skiponload: false});

Modified: openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as
===================================================================
--- openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-03-26 14:45:31 UTC (rev 8423)
+++ openlaszlo/trunk/WEB-INF/lps/lfc/kernel/swf/LzSprite.as	2008-03-26 15:01:54 UTC (rev 8424)
@@ -296,6 +296,10 @@
         //from this context, but it's not necessary.
         var mc = this.owner.immediateparent.sprite.attachResourceToChildView( resourceName, this );
         this.setMovieClip( mc , resourceName );
+        // Copy previous right-click context menu if there is one,
+        // from background-color movieclip.
+        var oldmenu = this.__LZbgRef.menu;
+        mv.menu = oldmenu;
     }
 
     this.resource = resourceName;
@@ -318,10 +322,15 @@
     var reclick = this.__LZbuttonRef._visible;
     this.__LZbuttonRef = null;
 
+    var oldmenu = this.__LZmovieClipRef.menu;
+    if (oldmenu == null) {
+        oldmenu = this.__LZbgRef.menu;
+    }
     var oldname = this.__LZmovieClipRef._name;
     var mc = this.owner.immediateparent.sprite.attachResourceToChildView( resourceName, this, oldname);
 
     this.setMovieClip( mc , resourceName );
+    mc.menu = oldmenu;
 
     if ( reclick ){
         this.setClickable( true );
@@ -541,6 +550,10 @@
         }
         this.__LZbgColorO.setRGB( bgc );
     }
+    // Reapply context menu if needed
+    if (this.__contextmenu) {
+        this.setContextMenu(this.__contextmenu);
+    }
 }
 
 
@@ -1650,6 +1663,12 @@
         }
         this._bgcolorhidden = true;
         mb.menu = cmenu;
+
+        // Install menu on foreground resource clip if there is one
+        var mc = this.getMCRef();
+        if (mc != null) {
+            mc.menu = cmenu;
+        }
     }
 
     if ($debug) {



More information about the Laszlo-checkins mailing list