Topic: "Menu attached to button" example

moro,

I tried to attach menu to a DIV element using attachTo() and found some bugs.

1. Menu is showing on both LEFT click.

I was happy to see LEFT click working, however I was not expecting that. Why is it attachTo() work with LEFT click and after normal instantiation it triggers with RIGHT?

2. Google Chrome, FF2, IE6 and IE7 also display native context menu on top of MifMenu (both on Buttons that you have in Demos AND my custom DIV). Only FF3 does not show native context menu.

I think attachTo() should configure menu trigger mouse button - left, right or both.

Thanks

Thumbs up Thumbs down

Re: "Menu attached to button" example

fixed, attachTo now show menu on left click only

Re: "Menu attached to button" example

disable native context menu if u want,

document.addEvent('contextmenu', function(event){
      event.preventDefault();
});

Re: "Menu attached to button" example

question. after I use attachTo('myDiv'), how can I reference 'myDiv' in all further actions?

attachTo: function(el){
    el=$(el);
    el.addEvents({
        'mousedown': function(event){
            if(event.rightClick) return;
            if(!this.isVisible()){
                this.$attaching=true;
                var coords=el.getCoordinates();
                this.show({x: coords.left + 10, y: coords.bottom - 15});
            }else{
                this.hide();
            }
    ......
}

It seems that all information on 'el' is lost forever. I need the original trigger to determine what menu actions should do.

thanks

Thumbs up Thumbs down

Re: "Menu attached to button" example

u attach one menu to different elements? Then attachTo not for you , create your own method.

Re: "Menu attached to button" example

what I want to do is similar to binding context menu to tree nodes. each node has unique Id and data associated with it.

are you saying that attachTo() should not be used in that case?

Thumbs up Thumbs down

Re: "Menu attached to button" example

yes, it's not for tree nodes. But i'm add ref to el.
U can do something like this now:

onAction: function(){
        alert(this.menu.el.get('id'));
}