Topic: MifTree and MifMenu integration

moro,

Can you post an example of how to show MifMenu depending on a clicked MifTree node?

Thank you

Re: MifTree and MifMenu integration

demo,    archive


Note: i made small hack in Mif.Tree::initEvents:

mousedown: function(){this.fireEvent('mousedown'); return false;}.bind(this),

Mif.Menu will be rewriten, now we have only this not easy way to attach and manipulate with menu.

var testMenu=new Mif.Menu({
                list: {
                    items: [
                        {
                            name: 'alert toggle state',
                            onAction: function(){
                                alert(this.menu.treeItem.isOpen() ? 'open' : 'close');
                            }
                        },
                        {
                            name: 'open',
                            onAction: function(){
                                alert('open');
                            }
                        }
                    ]
                }
            });
            
            tree.container.addEvent('contextmenu', function(event){
                var node=tree.mouse.node;
                if(!node) return;
                testMenu.show(event);
                testMenu.treeItem=tree.mouse.node;
                var item1=testMenu.list.items[1];
                item1.options.name=node.name;
                var container=item1.container;
                item1.draw();
                item1.container.replaces(container);
                return false;
            });
            
            tree.addEvent('mousedown', function(){
                testMenu.hide();
            });

Re: MifTree and MifMenu integration

I've just download MifMenu trunk and seems that is incompatible with Mootools 1.2  ...
Firebug return me :  "this.parent is not a function" on line 171 ...

this.parent($merge(this.options, {styles: {position: 'absolute'}}), 'mifmenu');

Re: MifTree and MifMenu integration

mootools 1.2? try 1.2.1, but it should work, mb u not include some files

this demo work in ff2

Re: MifTree and MifMenu integration

I'm running Mootools 1.2.1 
I've download Mif.Menu from your builder

Re: MifTree and MifMenu integration

all components? u include Mif.Container?
u download this demo archive, it's work?

Re: MifTree and MifMenu integration

I'm running Apple Mac OS X 10.5.5  with latest Firefox ...
I can't open context menu ... neither right or left click  doens't works ...

Re: MifTree and MifMenu integration

On you must do   CTRL + Left click  to fire contextmenu event ...
I've just discovered it !...

On windows it works with right button

Do this demo use mootools 1.2.1 ?

Re: MifTree and MifMenu integration

i'm install ff3.0.4 pc, works for me.

alt+left click - temporal fix for opera, because it's don't support contextmenu event

i don't know how contextmenu event should work on mac os

Re: MifTree and MifMenu integration

It works ... nice !
Thank you

Re: MifTree and MifMenu integration

good

Re: MifTree and MifMenu integration

this demo 1.2.0

13

Re: MifTree and MifMenu integration

Hi moro,
I've read that Mif.Menu is going to be rewritten, is that already done ? Or is the way of integrating MifTree and MifMenu you provided in 2008 still valid ?
Thanks in advance,
Jan

Re: MifTree and MifMenu integration

Mif.Menu under development. If you use old(because new not exist yet) menu version all old code will work, because nothing changed :-)

15

Re: MifTree and MifMenu integration

To add/delete nodes with Mif.Menu only do the following:

  var testMenu=new Mif.Menu({
    list: {
      items: [
      {
        name: 'Add node here',
        onAction: function() {
          var current = this.menu.treeItem;
              if(!current) return;
              tree.add({
                property: {
              name: "testnode"
            }
          }, current, 'inside');
        }
      },
      {
        name: 'Drop this node',
        onAction: function() {
          var current = this.menu.treeItem;
          if (!current) return;
          current.remove();
        }
      }
    ]
  }
});
            
  tree.container.addEvent('contextmenu', function(event){
    var node=tree.mouse.node;
    if(!node) return;
    testMenu.show(event);
    testMenu.treeItem=tree.mouse.node;
    return false;
  });

Re: MifTree and MifMenu integration

Mif.Menu 1.2 and Mif.Tree 1.2.6 demo

17

Re: MifTree and MifMenu integration

Hello, I have a problem with the integration

I have this definition of a menu :

    var testMenu = new Mif.Menu().load([
            {
                name: 'open',
                action: function()
                {
                    var current = this.treeItem;
                    if(!current) return;

                    alert('open : ' + current.id);
                }
            },
            {
                name: 'remove',
                disabled: true
            },
            {
                name: 'exit',
                id: 'exit'
            }
        ]);

With this event on the tree (otree) :

    otree.container.addEvent("contextmenu", function(event)
        {
            var node = otree.mouse.node;
            if(!node) return;

            testMenu.treeItem = node;
            testMenu.show(event);

            return false;
        });

My problem is when I do a rigth-click nearby the label/name of the tree, the menu is visible, if I click on the label/name, nothing to do

The code is ok with a old version of tree+menu, but with the last version, I have this problem.

Re: MifTree and MifMenu integration

Duduche1 wrote:

Hello, I have a problem with the integration
...
My problem is when I do a rigth-click nearby the label/name of the tree, the menu is visible, if I click on the label/name, nothing to do

The code is ok with a old version of tree+menu, but with the last version, I have this problem.

works for me http://mifjs.net/misc/tree_menu/

19

Re: MifTree and MifMenu integration

Thanks, I have redo my code, and now it's ok.
i don't know why with all javascript in "source" folder .... I have the error, with only one "js" no problem.