The context menu mechanism needs a Flash movieclip to attach the menu
to. But in some cases that movieclip does not exist. The code
currently looks for the view's foreground movieclip,  , and for a
background movieclip (used to set the
bgcolor of a view).   Note that if neither exists, there is no way to
set the menu on that
view. This is a bug which we need to fix, by having a dedicated
transparent "menu movieclip" that
can be attached when a menu is attached
(http://jira.openlaszlo.org/jira/browse/LPP-3852 )


In your case, the dynamically loaded resource loads a new movieclip into
the view, and this  new movieclip will not have the menu attached
anymore. A workaround is below, which is to
trigger on the resource onload event, and attach the menu after the
resource has loaded:


<canvas debug="true">
  <view bgcolor="white">
     <method event="oninit" >
        this.setSource('../resources/jpg/logo.jpg');

     </method>
     <handler name="onload">
        var cm = new LzContextMenu();
        var item = cm.makeMenuItem('insertasd', new LzDelegate(this, 'insert'));
        cm.addItem(item);
        this.setContextMenu(cm);
     </handler>

     <method name="insert">
       Debug.write('called insert', this);
     </method>

  </view>
</canvas>





On 9/6/07, William Powell <[EMAIL PROTECTED]> wrote:
> Hi
> I see the same thing as you do, with your code below.
> I also see the problem if I use the image in the tab
> datapath. However, if I add a resource to the canvas,
> and then pint to the resource in the view, the context
> menu item gets added. Does anyone know if this is a
> bug or expected behaviour?
> Bill Powell
> --- taocore <[EMAIL PROTECTED]> wrote:
>
> >
> > It seems that can not install contextmenu on view
> > which loads resource
> > dynamically. Any sugguestions?
> >
> >
> > Try the code blow:
> >
> >
> > <canvas debug="true">
> >
> >    <view bgcolor="white">
> >
> >       <method event="oninit" >
> >
> >          this.setSource('cd_cover.jpg');
> >
> >          var cm = new LzContextMenu();
> >
> >          var item = cm.makeMenuItem('insertasd', new
> > LzDelegate(this,
> > 'insert'));
> >
> >          cm.addItem(item);
> >
> >          this.setContextMenu(cm);
> >
> >       </method>
> >
> >    </view>
> >
> > </canvas>
> >
> >
> >
> >
> > taocore
> >
>
>
>
>
> ____________________________________________________________________________________
> Pinpoint customers who are looking for what you sell.
> http://searchmarketing.yahoo.com/
>


-- 
Henry Minsky
Software Architect
[EMAIL PROTECTED]

Reply via email to