There are some known bugs with the way the context menu API is implemented right now, I'm working on an improved library. There is also a known bug where calling "bringToFront" on any view will erase the existing context menus from most views.

I'll post a patch to this mailing list when I have it ready.

In the meantime, here is something which may demonstrate a workaround

<script>
LzView.prototype.changeOrder = function (cView , dir , fv , inf ){
    var dl = this.getDepthList();
    var dll = dl.length;
    var sw;
    if ( fv ){
        //need to figure out which direction we're going in
        var foundcView = false;
        var foundfv = false;
        var dir = 0;
        for ( var i = 0; i < dll; i++ ){
            var v = dl[ i ];
            if ( !v ) {
                continue;
            } else if ( v == cView ){
                if ( foundfv ) {
                    dir = -1;
                    if ( inf ){
                        sw = fv;
                    } else {
                        sw = heldf;
                    }
                    break;
                }
                foundcView = true;
            } else if (v == fv ){
                if ( foundcView ) {
                    dir = 1;
                    if ( inf ){
                        sw = this.__LZfindNextNonNull( dl , i , 1 );
                    } else {
                        sw = fv;
                    }
                    break;
                }
                foundfv = true;
                if (!inf ){
                    var heldf = this.__LZfindNextNonNull( dl , i , -1 );
                }
            }
        }
    }

    if ( dir == 0) return false;

    var next = dir;
    var nv;
    if ( cView.__LZmovieClipRef == null ){
        cView.makeContainerResource();
    }

    var cVMv = this.getAttachPoint( cView );

    var reback = cView.__LZisBackgrounded;
    var menu = null;
    if (reback) {
        menu = cView.__LZbgRef.menu;
    }
    cView.removeBG();
    while (cView.__LZdepth + next < dl.length  && cView.__LZdepth+next >= 0 ){
        var d = cView.__LZdepth;
        nv = dl[ d+next ];
        if ( nv == null ){
            //there's no view there. We have to skip it.
            next += dir;
            continue;
        } else if ( nv == sw ){
            break;
        }

        var movnv = this.getAttachPoint( nv );

        if ( !movnv ){
            nv.makeContainerResource();
            movnv = this.getAttachPoint( nv );
        }
        movnv.swapDepths( cVMv );
        // Krank annotation
        if (_root.$krank) {
          var tmp = cVMv.$SID_DEPTH;
          cVMv.$SID_DEPTH = movnv.$SID_DEPTH;
          movnv.$SID_DEPTH = tmp;
        }

        nv.__LZdepth = d;
        cView.__LZdepth = d+next;
        next = dir;

        if ( nv.__LZisBackgrounded ){
            var menu2 = nv.__LZbgRef.menu;
            nv.removeBG();
            nv.applyBG();
            nv.__LZbgRef.menu = menu2;
        }
    }

    if ( reback ){
        cView.applyBG();
        cView.__LZbgRef.menu = menu;
    }
    return true;
}

</script>



<view name="myview" width="100" height="100" bgcolor="#ffcc00">
  <method event="oninit">
    var newMenu = new ContextMenu();
    newMenu.hideBuiltInItems();
    var item1 = new ContextMenuItem('item1', function () { _root.myview.fun(); } );
    newMenu.addItem(item1);
    this.setContextMenu(newMenu);
  </method>
 
  <method name="fun">
    md.open();
  </method>
</view>

<modaldialog id="md" width="200" height="200">
  <simplelayout/>
  <text>This is your dialog</text>
  <button isdefault="true">OK</button>
</modaldialog>




On 11/25/05, eealzhang(��亮=研�l) <[EMAIL PROTECTED]> wrote:
Dear,

        Yes, I have see that before, thanks, I'll try it.
        So In you way, the nested views could not have their own constexmenu?
        And thanks for your help

======= 2005-11-25 19:09:55 In your mail =======

>eealzhang,hi!
>
>           Just tested the right click menu in 3.1, two results found:
>
>1.the method(metioned in doc) to remove default lazlo contextmenu is invalid! it still there!
>2.the contexmenu can not define in nested views, otherwise,one of them will be invalid!
>
>moreover,  while replacing the embed.js in 3.1 with that of 3.0,the context menu even don't appear at all!
>
>     Do you have the same experience?
>       
>
>     Regards
>        rabbit69
>        [EMAIL PROTECTED]
>          2005-11-25

= = = = = = = = = = = = = = = = = = = =

Best Regards!
And have a nice day!
Zeal


eealzhang(��亮=研�l)
[EMAIL PROTECTED]
2005-11-25


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






--
Henry Minsky
Software Architect
[EMAIL PROTECTED]

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

Reply via email to