Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:54
Context Menu on Treemenu
Poster: Shap5202
Dated: Thursday September 21 2006 - 22:52:03 BST
I'm trying to create a tree (ok, well I did that already). And then make it so you have options to select on various nodes in the tree. It doesn't have to be a context menu, that's just the option that I'm trying right now (which not much luck).
I modified the context-menu code to try and handle this as such:
Code:
var selected = _mi[_itemRef];
if(selected && selected[34] == "tree" && selected[103]) {
var treeContext = selected[103] + "_popup";
popup(treeContext,1);
}else {
_gm=getMenuByName(contextMenu)
if(_gm!=null)popup(contextMenu,1)
}
if(selected && selected[34] == "tree" && selected[103]) {
var treeContext = selected[103] + "_popup";
popup(treeContext,1);
}else {
_gm=getMenuByName(contextMenu)
if(_gm!=null)popup(contextMenu,1)
}
So if the selected item is a tree and has an id set, popup the menu with name id + "_popup" (which i can assume exists). And it kinda of works, but in many cases the tree is overtop the menu (zindex?) or the menu doesn't even show up at all depending on where I click on the item.
The other option would be to only expand the menu when you click on the +/- and clicking on the menu test itself would open up a popup menu of additional options. But that would seem to be much trickier and possibly involve the main milonic code which is out.
And here's my tree data, not that it will probably help much.
Code:
_scrollAmount=5; // Used for Netscape 4 scrolling
_scrollDelay=10; // Used for Netscape 4 scrolling
_menuCloseDelay=500; // The delay for menus to remain visible on mouse off
_menuOpenDelay=150; // The delay for opening menus on mouse over
_subOffsetTop=0; // Sub menu offset Top position
_subOffsetLeft=0; // Sub menu offset Left position
treeOffset=17; // Used to set the offset of sub menus
singleMasterMenu=false; // Informs the system to only have one menu open at a time
with(tstyle1=new mm_style()){
menubgimage="images/tree_bg.gif";
offcolor="black";
oncolor="blue";
//clickcolor="blue";
decoration="none";
ondecoration="underline";
fontfamily="verdana,arial,tahoma";
fontsize="68%";
type="tree";
margin=0;
padding=0;
separatorsize=0;
subimage="images/tree_trans.gif"
subimageposition="top left" ;
zindex=-1;
}
with(tstyle2=new mm_style()){
//menubgimage="images/tree_bg.gif";
offcolor="black";
oncolor="blue";
//clickcolor="blue";
decoration="none";
ondecoration="underline";
fontfamily="verdana,arial,tahoma";
fontsize="68%";
type="tree";
margin=0;
padding=0;
separatorsize=0;
subimage="images/tree_trans.gif"
subimageposition="top left" ;
}
with(sectionMenuStyle=new mm_style()){
bordercolor="#9BA6C2";
borderstyle="solid";
borderwidth=0;
closeonclick=true;
fontfamily="arial, tahoma";
fontsize="12px";
fontstyle="normal";
headerbgcolor="#94BCF8";
headerborder="1px solid #1852D8";
headercolor="#000000";
itemheight=25;
imagepadding=4;
menubgcolor="#FFFFFF";
offbgcolor="transparent";
offcolor="#000000";
onbgcolor="#FEFAD2";
oncolor="#000000";
image="images/16_blank.gif"
menubgimage="images/submenu_bkg.gif";
overbgimage="images/submenu_hover_bkg.gif";
}
with(new menuname("primary_popup")){
style=sectionMenuStyle;
alwaysvisible=0;
orientation="vertical";
aI("text=Summary;");
aI("text=Update;");
aI("text=Delete;");
}
with(new menuname("fs1_popup")){
style=sectionMenuStyle;
alwaysvisible=0;
orientation="vertical";
aI("text=Summary;");
aI("text=Update;");
aI("text=Delete;");
}
with(new menuname("Primary")){
style=tstyle2;
alwaysvisible=1;
position="absolute";
aI("text=Customer: Harold Martinez;id=primary;image=images/icon_ep.gif;showmenu=CustomerPrimary;
offclass=treeBeginLoneItemCollapsed;
clickclass=treeBeginLoneItemExpanded;");
}
with(new menuname("CustomerPrimary")){
style=tstyle2;
aI("text=Commitment: 100001;showmenu=Commitment100001;clickfunction=popup('Commitment100001_pop', 1);image=images/icon_menu.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemCollapsed;clickclass=treeItemExpanded;");
aI("text=Commitment: 200023;showmenu=Commitment200023;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemCollapsed;
clickclass=treeItemExpanded;");
aI("text=Loan: 230043;showmenu=Loan230043;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemCollapsed;
clickclass=treeItemExpanded;");
aI("text=Commitment: 230053;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 1;id=fs1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 2;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 3;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment100001")){
style=tstyle1;
aI("text=Fee: Type 1;image=images/icon_item.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemBranch;");
aI("text=Fee: Type 2;image=images/icon_item.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemBranch;");
aI("text=Commitment: 343033;showmenu=Commitment343033;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;
offclass=treeItemCollapsed;clickclass=treeItemExpanded;");
}
with(new menuname("Commitment343033")){
style=tstyle1;
aI("text=Fee: Type 1;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment200023")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Loan: 1230404;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment200023")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Loan: 1230404;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Loan230043")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeEndItem;");
}
drawMenus();
_scrollDelay=10; // Used for Netscape 4 scrolling
_menuCloseDelay=500; // The delay for menus to remain visible on mouse off
_menuOpenDelay=150; // The delay for opening menus on mouse over
_subOffsetTop=0; // Sub menu offset Top position
_subOffsetLeft=0; // Sub menu offset Left position
treeOffset=17; // Used to set the offset of sub menus
singleMasterMenu=false; // Informs the system to only have one menu open at a time
with(tstyle1=new mm_style()){
menubgimage="images/tree_bg.gif";
offcolor="black";
oncolor="blue";
//clickcolor="blue";
decoration="none";
ondecoration="underline";
fontfamily="verdana,arial,tahoma";
fontsize="68%";
type="tree";
margin=0;
padding=0;
separatorsize=0;
subimage="images/tree_trans.gif"
subimageposition="top left" ;
zindex=-1;
}
with(tstyle2=new mm_style()){
//menubgimage="images/tree_bg.gif";
offcolor="black";
oncolor="blue";
//clickcolor="blue";
decoration="none";
ondecoration="underline";
fontfamily="verdana,arial,tahoma";
fontsize="68%";
type="tree";
margin=0;
padding=0;
separatorsize=0;
subimage="images/tree_trans.gif"
subimageposition="top left" ;
}
with(sectionMenuStyle=new mm_style()){
bordercolor="#9BA6C2";
borderstyle="solid";
borderwidth=0;
closeonclick=true;
fontfamily="arial, tahoma";
fontsize="12px";
fontstyle="normal";
headerbgcolor="#94BCF8";
headerborder="1px solid #1852D8";
headercolor="#000000";
itemheight=25;
imagepadding=4;
menubgcolor="#FFFFFF";
offbgcolor="transparent";
offcolor="#000000";
onbgcolor="#FEFAD2";
oncolor="#000000";
image="images/16_blank.gif"
menubgimage="images/submenu_bkg.gif";
overbgimage="images/submenu_hover_bkg.gif";
}
with(new menuname("primary_popup")){
style=sectionMenuStyle;
alwaysvisible=0;
orientation="vertical";
aI("text=Summary;");
aI("text=Update;");
aI("text=Delete;");
}
with(new menuname("fs1_popup")){
style=sectionMenuStyle;
alwaysvisible=0;
orientation="vertical";
aI("text=Summary;");
aI("text=Update;");
aI("text=Delete;");
}
with(new menuname("Primary")){
style=tstyle2;
alwaysvisible=1;
position="absolute";
aI("text=Customer: Harold Martinez;id=primary;image=images/icon_ep.gif;showmenu=CustomerPrimary;
offclass=treeBeginLoneItemCollapsed;
clickclass=treeBeginLoneItemExpanded;");
}
with(new menuname("CustomerPrimary")){
style=tstyle2;
aI("text=Commitment: 100001;showmenu=Commitment100001;clickfunction=popup('Commitment100001_pop', 1);image=images/icon_menu.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemCollapsed;clickclass=treeItemExpanded;");
aI("text=Commitment: 200023;showmenu=Commitment200023;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemCollapsed;
clickclass=treeItemExpanded;");
aI("text=Loan: 230043;showmenu=Loan230043;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemCollapsed;
clickclass=treeItemExpanded;");
aI("text=Commitment: 230053;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 1;id=fs1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 2;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Financial Statement: Type 3;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment100001")){
style=tstyle1;
aI("text=Fee: Type 1;image=images/icon_item.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemBranch;");
aI("text=Fee: Type 2;image=images/icon_item.gif;clickimage=images/icon_menu_open.gif;
offclass=treeItemBranch;");
aI("text=Commitment: 343033;showmenu=Commitment343033;image=images/icon_menu.gif;
clickimage=images/icon_menu_open.gif;
offclass=treeItemCollapsed;clickclass=treeItemExpanded;");
}
with(new menuname("Commitment343033")){
style=tstyle1;
aI("text=Fee: Type 1;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeItemBranch;");
aI("text=Fee: Type 4;image=images/icon_item.gif;
clickimage=images/icon_menu_open.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment200023")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Loan: 1230404;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Commitment200023")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Loan: 1230404;image=images/icon_item.gif;offclass=treeEndItem;");
}
with(new menuname("Loan230043")){
style=tstyle1;
aI("text=Financial Statement: Type 1;image=images/icon_item.gif;offclass=treeItemBranch;");
aI("text=Creditor Report: Type 1;image=images/icon_item.gif;offclass=treeEndItem;");
}
drawMenus();