Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Luis Domingues on Nov 23, 2008 05:05
open dhtmlx forum
dhtmlxMenu - control-click

Hello,

I need the control-click operation to open the menu option in a new tab, but I doesn't work. I've been looking for a controlClick event, but couldn't find one.

Also, is there a better way to embed a link in a menu option (like href used to work for the previous version of dhtmlxMenu) ? Using html inside the text element takes more space than just using the deprecated href parameter.


Here's my code:
<?xml version="1.0"?>
<menu>

    <item id="m0.1.1" text='<a href="index.php?process=start_do">Start</a>'text="Start" img="wi0149-16.png">

        <item id="m0.2.1" text='<a href="index.php?process=users_myprofile_show">My Profile</a>'text="My Profile" img="ac0021-16.png">

            <item id="m0.3.1" text='<a href="index.php?process=users_myprofile_show">Show Perfil</a>'text="Show Perfil"/>

            <item id="m1.3.2" text='<a href="index.php?process=my_searches_list">My Searches</a>'text="My Searches"/>


        </item>
</item>
</menu>



<link rel="stylesheet" type="text/css" href="modules/dhtmlxsuite/dhtmlxMenu/codebase/skins/dhtmlxmenu_modern_blue.css">
<script src="modules/dhtmlxsuite/dhtmlxMenu/sources/dhtmlxcommon.js"></script>
<script src="modules/dhtmlxsuite/dhtmlxMenu/sources/dhtmlxmenu.js"></script>

<script>
    var menu;
    menu = new dhtmlXMenuObject("menuObj", "modern_blue");
    menu.setImagePath("modules/dhtmlxsuite/dhtmlxMenu/codebase/imgs/");
    menu.setIconsPath("images/menuicons/");
    menu.loadXML("menu.xml");
</script>
Answer posted by Support on Nov 24, 2008 04:03
Hello,

For the moment dhtmlxMenu 2.0 does not support href as a independent attribute.
Control-click also absent. Probably it will added in future version.
Answer posted by Luis Domingues on Nov 24, 2008 04:16
Is it possible to implement the right-click to open in a new tab?
Answer posted by Support on Nov 24, 2008 05:54
Source codes need to be fixed.

You can try do it yourself. Edit the dhtmlxmenu.js file:

m.onclick = function(e) {
    ...
    main_self._doOnClick(...
    ...
}

k.onclick = function(e) {
    ...
}
Answer posted by Luis Domingues on Nov 26, 2008 14:15
I did change it:
    this._doOnClick = function(id, type) {
        this.menuLastClicked = id;

        link=this.getItemLink(id);
        if(link!="") window.location=link;
        return;


I just don't know how to detect right-click... I've tried this:

    this._doOnClick = function(id, type, e) {
        this.menuLastClicked = id;

        link=this.getItemLink(id);
        if(link!="")
        {
            if (e.button == 2)
            {
                alert(1);
            }
            else
            {
                window.location=link;
            }
        }
        return;


......... in m.onclick = function(e) {
        main_self._doOnClick(this.id.replace(main_self.idPrefix, ""), tc+td+"t", e);

.......... in     k.onclick = function(e) {

            case "item":
                main_self._doOnClick(this.id.replace(main_self.idPrefix, ""), tc+td+"n", e);

Answer posted by Support on Dec 03, 2008 07:35
Your code is correct, then in event handler you should parse 3rd incoming argument like this:

menu.attachEvent("onClick", function(id, t, e){
    // parsing event
    if (e.ctrlKey) {
       // was pressed
    } else {
       // was not pressed
    }
});