Attach menu to button
Context menu attached to button "conf"
</> Source
<!DOCTYPE html>
<html>
<head>
<title>Attach menu to button</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/fonts/font_roboto/roboto.css"/>
<link rel="stylesheet" type="text/css" href="../../../codebase/dhtmlx.css"/>
<script src="../../../codebase/dhtmlx.js"></script>
<style>
/* conf, enabled state */
.dhxwins_vp_material div.dhxwin_hdr div.dhxwin_btns div.dhxwin_button.dhxwin_button_conf {
background-image: url(../common/button_conf.png);
background-position: 0px 0px;
}
/* conf, disabled state */
.dhxwins_vp_material div.dhxwin_hdr div.dhxwin_btns div.dhxwin_button_dis.dhxwin_button_conf_dis {
background-image: url(../common/button_conf.png);
background-position: 0px -24px;
}
/* conf, pressed state */
.dhxwins_vp_material div.dhxwin_hdr div.dhxwin_btns div.dhxwin_button.dhxwin_button_conf_pressed {
background-image: url(../common/button_conf.png);
background-position: 0px 0px;
background-color: #3090c0!important;
}
.dhxwins_vp_material div.dhxwin_hdr div.dhxwin_btns div.dhxwin_button_dis.dhxwin_button_conf_pressed_dis {
background-image: url(../common/button_conf.png);
background-position: 0px -24px;
background-color: #f0f0f0!important;
}
div#winVP {
position: relative;
height: 350px;
border: #dfdfdf 1px solid;
margin: 10px;
}
div#objId {
position: relative;
width: 100%;
height: 100%;
font-family: Roboto, Arial, Helvetica;
font-size: 14px;
color: #404040;
overflow: auto;
}
</style>
<script>
var dhxWins, w1, myMenu, myMenu2;
function doOnLoad() {
dhxWins = new dhtmlXWindows();
dhxWins.attachViewportTo("winVP");
w1 = dhxWins.createWindow("w1", 20, 30, 320, 200);
w1.addUserButton("conf", 0, "Configure");
w2 = dhxWins.createWindow("w2", 50, 70, 320, 200);
w2.addUserButton("conf", 0, "Configure");
myMenu = w1.button("conf").attachContextMenu({
icons_path: "../common/menu/",
xml: "../common/menu/menu.xml"
});
myMenu2 = w2.button("conf").attachContextMenu({
icons_path: "../common/menu/",
xml: "../common/menu/menu2.xml"
});
// add custom style to emulate pressed button while opened
myMenu.attachEvent("onShow", function(){
w1.button("conf").setCss("conf_pressed"); // set "pressed state"
});
myMenu.attachEvent("onHide", function(){
w1.button("conf").setCss("conf"); // clear "pressed state"
});
myMenu2.attachEvent("onShow", function(){
w2.button("conf").setCss("conf_pressed"); // set "pressed state"
});
myMenu2.attachEvent("onHide", function(){
w2.button("conf").setCss("conf"); // clear "pressed state"
});
}
function doOnUnload() {
if (dhxWins != null) {
dhxWins.unload();
dhxWins = w1 = myMenu = null;
}
}
</script>
</head>
<body onload="doOnLoad();" onunload="doOnUnload();">
<div id="winVP"></div>
<div id="objId" style="">
<div style="margin: 5px 8px;">
Context menu attached to button "conf"
</div>
</div>
</body>
Documentation
Check documentation to learn how to use the components and easily implement them in your applications.