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:05
Right Click context menu how do I close it before I load it?
Poster: darkcircuituk
Dated: Friday October 29 2004 - 14:26:10 BST
I have implemented frames on my website and as I wish to continue the right click menu across the frames, I have implemented the right click context menu on each page within the frames. This causes a major problem because now I can actually have several of the right click menus open at once (one on each frame).
Is it possible to close any open right click menus on any frame when someone right clicks again on any of the frames?
Thanks
Dave
Poster: kevin3442
Dated: Wednesday November 3 2004 - 2:55:58 GMT
Hi Dave,
The good news is that is should be possible. To do what you want would require looping through the frames and closing menus that are open in those frames before opening the new menu. The not-so-good news is that you'd have to edit the event handler that opens the context menu. That code is in contextmenu.js, which is copyrighted by Milonic, so it's not really for me to just edit as I see fit. I'll check to see if it's do-able.
Kevin
Thanks Kevin
Poster: darkcircuituk
Dated: Monday November 8 2004 - 11:34:23 GMT
If you could do that for me and get back to me about it that would be great, thanks
Dave
Slight Problem
Poster: darkcircuituk
Dated: Monday November 8 2004 - 11:41:42 GMT
I just checked and I am not implementing the contextmenu.js file, I am only implementing: menu_data.js, milonic_src.js and mmenudom.js. The right click menu seems to be running fine though, what functionality does the contextmenu.js file bring to the menu?
Thanks
Dave
Re: Slight Problem
Poster: kevin3442
Dated: Tuesday November 9 2004 - 7:38:10 GMT
Hi Dave,
darkcircuituk wrote:
I just checked and I am not implementing the contextmenu.js file, I am only implementing: menu_data.js, milonic_src.js and mmenudom.js. The right click menu seems to be running fine though, what functionality does the contextmenu.js file bring to the menu?
contextmenu.js provides the functionality for context menus, so you must be using the code somewhere. Out of curiosity, I had a look at some of your earlier posts. At some point, you moved the essential code from contextmenu.js into your menu_data.js file. So, your menu_data.js file contains the event handler that's normally defined in contextmenu.js.
I have sent a note about the situation to Milonic. I'll report any answer I get back here.
Cheers,
Kevin
Excellent, Thanks
Poster: darkcircuituk
Dated: Monday November 15 2004 - 9:46:28 GMT
Thats great, thank you very much!
Got an Answer Yet Kevin?
Poster: darkcircuituk
Dated: Thursday November 25 2004 - 11:18:10 GMT
Hey Kevin, you got an answer back from Milonic yet?
Poster: Andy
Dated: Thursday November 25 2004 - 11:23:39 GMT
Hi,
It should be possible by calling the closeAllMenus function on each of your frames.
Something like this might do it:
frame1.closeAllMenus()
frame2.closeAllMenus()
Not tested it but it should work. If i had a URL, I could maybe write write a function to do it
Cheers
Andy
Errrmmmm not too sure
Poster: darkcircuituk
Dated: Thursday November 25 2004 - 11:32:46 GMT
Errrrrrrrr won't that just close all open menus if they are within the same js file, my problem is I am using two seperate js files, one for each different menu :-S
I can send you an example of what I am trying to achieve!
Poster: Andy
Dated: Thursday November 25 2004 - 11:43:06 GMT
It will only close the volatile menus. Static (alwaysvisible) menus will remain open.
I'm guessing that if you have a context menu open, then you can't also have a pull down menu open so it won't be a problem.
-- Andy
Poster: kevin3442
Dated: Saturday December 4 2004 - 0:02:41 GMT
Hi Dave,
Sorry it took me so long to reply. I've been traveling for the past couple of weeks and haven't had much time for the net.
I think Andy's post suggests pretty much the same thing I was suggesting. Calling the built-in closeAllMenus() function in each of the frames before opening the next context menu should take care of the issue. Seems to me the logical place to do thath would be withing the right-click event handler (which is normally defined in contextmenu.js, but which you seem to have moved into your menu_data.js file).
Suppose, for example, that you have three frames named "header", "side", and "body". You could find the following code:
Code:
function rclick(e){
if(contextDisabled)
{
_d.oncontextmenu=null
return true;
}
if(_d.all)
{
ev=event.button;
contextObject=event.srcElement
}
<... etc ...>
}
if(contextDisabled)
{
_d.oncontextmenu=null
return true;
}
if(_d.all)
{
ev=event.button;
contextObject=event.srcElement
}
<... etc ...>
}
and change it to:
Code:
function rclick(e){
if(contextDisabled)
{
_d.oncontextmenu=null
return true;
}
top.header.closeAllMenus();
top.side.closeAllMenus();
top.body.closeAllMenus();
if(_d.all)
{
ev=event.button;
contextObject=event.srcElement
}
<... etc ...>
}
if(contextDisabled)
{
_d.oncontextmenu=null
return true;
}
top.header.closeAllMenus();
top.side.closeAllMenus();
top.body.closeAllMenus();
if(_d.all)
{
ev=event.button;
contextObject=event.srcElement
}
<... etc ...>
}
You would, of course, make your code appropriate to the number of frames you have as well as their actual names. How you address the frames from the top would also depend on whether or not you have any nested frames.
Here's another option:
Another approach you could take would be to apply slight left and top offset to each your context menus, moving them slightly up and to the left when they open. Offset the menus just enough so that when they open, the pointer is automatically inside of the menu, highlighting the first item. That way, if the user decides not to do anything with the open menu, when he or she moves the pointer out of the menu, the menu will close automatically.
To apply an "up and left" offset, you'd use the top and left properties in the menu definition, like so:
Code:
with(milonic=new menuname("contextMenu")){
top="offset=-3";
left="offset=-3";
style = contextStyle;
margin=3
aI("text=Milonic Home Page;url=/;image=http://www.milonic.com/images/home.gif");
aI("text=Print;url=javascript:window.print();separatorsize=1;image=http://www.milonic.com/images/print.gif");
<...etc...>
}
top="offset=-3";
left="offset=-3";
style = contextStyle;
margin=3
aI("text=Milonic Home Page;url=/;image=http://www.milonic.com/images/home.gif");
aI("text=Print;url=javascript:window.print();separatorsize=1;image=http://www.milonic.com/images/print.gif");
<...etc...>
}
If you didn't want the first active item to be highlighted automatically, then you could use a header item at the top of the menu.
Hope that helps,
Kevin