[Laszlo-dev] UPDATED For Review: Change 20080326-hqm-F Summary: fix for context-menu bug on views with image resource

André Bargull a.bargull at intensis.de
Wed Mar 26 12:29:08 PDT 2008


In the following testcase, not all images receive properly the view's 
contextmenu.

@Max:
Why do I need to make that view visible again, mysteriously it's 
visible-property is set to "false"!?
<view width="250" height="60" 
    
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
    oninit="canvas.makeContextMenu(this); this.setBGColor(red);"
    onload="this.setResource('http:LPP-5636.png');this.setVisible(true);" />

---
<canvas debug="true" oninit="canvas.makeContextMenu(this)" >
   
    <resource name="rsc" src="LPP-5636.png" />
   
    <attribute name="httprsc" 
value="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif" 
type="string" />
    <attribute name="ctxmenu_uid" value="0" type="number" />
   
    <simplelayout axis="x" spacing="10" />

    <method name="makeContextMenu" args="who" >
        var cm = new LzContextMenu();
        cm.addItem(cm.makeMenuItem(who.constructor.tagname + ' ' + 
(canvas.ctxmenu_uid++)));
        who.setContextMenu(cm);
    </method>
   
    <view>
        <simplelayout axis="y" spacing="10" />
        <text>normal views</text>
       
        <view width="250" height="60" 
oninit="canvas.makeContextMenu(this)" />
        <view width="250" height="60" 
oninit="canvas.makeContextMenu(this); this.setBGColor(red);" />
        <view width="250" height="60" bgcolor="yellow" 
oninit="canvas.makeContextMenu(this);" />
        <view width="250" height="60" bgcolor="yellow" 
oninit="canvas.makeContextMenu(this); this.setBGColor(red);" />
    </view>
   
    <view>
        <simplelayout axis="y" spacing="10" />
        <text>views with resources</text>
       
        <view width="250" height="60"
            
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
            oninit="canvas.makeContextMenu(this)" />
   
        <view width="250" height="60" bgcolor="blue"
            
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
            oninit="canvas.makeContextMenu(this)" />
   
        <view width="250" height="60"
                resource="rsc"
                oninit="canvas.makeContextMenu(this)" />
               
        <view width="250" height="60" bgcolor="blue"
                resource="rsc"
                oninit="canvas.makeContextMenu(this)" />
       
        <view width="250" height="60"
                resource="rsc"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(red);" />
               
        <view width="250" height="60" bgcolor="blue"
                resource="rsc"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(red);" />
       
        <!-- these do not work -->
        <!--
        <view width="250" height="60" bgcolor="blue"
                resource="rsc"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(red); /*this.setResource(canvas.httprsc);*/" />
       
        <view width="250" height="60" 
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(yellow); this.setResource('rsc');
                Debug.write('%w - %d x %d', this, this.x, this.y);" />
       
        <view width="250" height="60" bgcolor="blue"
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(yellow); this.setResource('rsc');
                Debug.write('%w - %d x %d', this, this.x, this.y);" />
        -->
       
        *<!-- no context menu on the image for the following four views -->
        <view width="250" height="60" 
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(yellow);"
                onload="this.setResource('rsc');" />
       
        <view width="250" height="60" bgcolor="blue"
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); 
this.setBGColor(yellow);"
                onload="this.setResource('rsc');" />
               
        <!-- mysteriously these get invisible -->
        <view width="250" height="60" 
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); this.setBGColor(red);"
                
onload="this.setResource('http:LPP-5636.png');this.setVisible(true);" />
       
        <view width="250" height="60" bgcolor="blue"
                
resource="http://www.openlaszlo.org/themes/manji/images/ol_logo_small.gif"
                oninit="canvas.makeContextMenu(this); this.setBGColor(red);"
                
onload="this.setResource('http:LPP-5636.png');this.setVisible(true);" />*
    </view>
   
    <view>
        <simplelayout axis="y" spacing="10" />
        <text>texts</text>
       
        <text text="contextmenu" oninit="canvas.makeContextMenu(this)" />
        <text bgcolor="0xeaeaea" text="contextmenu" 
oninit="canvas.makeContextMenu(this)" />
        <inputtext text="contextmenu" 
oninit="canvas.makeContextMenu(this)" />
        <inputtext bgcolor="0xeaeaea" text="contextmenu" 
oninit="canvas.makeContextMenu(this)" />
    </view>
   
</canvas>


On 3/26/2008 3:46 PM, Henry Minsky wrote:
> 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
>
>
>
> Files:
> M      kernel/swf/LzMakeLoadSprite.as
> M      kernel/swf/LzSprite.as
>
> Changeset: 
> http://svn.openlaszlo.org/openlaszlo/patches/20080326-hqm-F.tar
>


More information about the Laszlo-dev mailing list