Right-click Context menu

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
User avatar
CyrixInstead
Beginner
Beginner
Posts: 5
Joined: Sat Sep 20, 2003 4:27 pm
Location: Stoke-on-Trent
Contact:

Right-click Context menu

Post by CyrixInstead »

I noticed a new function on the Milonic site that shows a right-click context menu. Currently, the link to download is the standard horizontal menu.

I like it very much, and was wondering if anyone could tell me when it would become available to use/download.


~Cyrix
There are 10 types of people in the world: those who can read binary, and those who can't.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Pretty nifty, isn't it?

Andy is up to his eyeballs in projects right now, but we're workin' on him. Stay tuned!
John
User avatar
CyrixInstead
Beginner
Beginner
Posts: 5
Joined: Sat Sep 20, 2003 4:27 pm
Location: Stoke-on-Trent
Contact:

Post by CyrixInstead »

Yeah it's very cool, and looks very professional.

I can't wait to add it to my site and make that look more professional!

~Cyrix
There are 10 types of people in the world: those who can read binary, and those who can't.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Trust me, everything Andy does is professional - period.

For now just enjoy the menu system - this will come...
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

Please explain, I don't see it.
Thanks
maz
User avatar
CyrixInstead
Beginner
Beginner
Posts: 5
Joined: Sat Sep 20, 2003 4:27 pm
Location: Stoke-on-Trent
Contact:

Post by CyrixInstead »

Just go to the main Milonic website i.e. http://milonic.com and right-click your mouse. Rather than the standard Windows context menu you get a cool Milonic one.

~Cyrix
There are 10 types of people in the world: those who can read binary, and those who can't.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Unless you've got a 2 or 3 button mouse on that thing, it won't work, Maz. You might try a Cmd-click.
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

It must be the new page I activated it by using my finger pad.
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Not sure what you mean by 'new page'. We're talking about a contextual menu that pops up anywhere on the page that you do a right click.
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

I don't see it then.
User avatar
Hergio
Milonic God
Milonic God
Posts: 1123
Joined: Wed Jun 12, 2002 7:46 pm
Location: Rochester, NY

Post by Hergio »

Might be your browser. Go to the homepage and wait for the page to completely finish loading, then RIGHT click on the page. Or do whatever it is you do usually to get the Context menu to show up (the menu you use to save images or view the source on a webpage). If you cant see it, then I guess its your browser.
Dave Hergert
Software Engineer
"Helping to make the menu better, one :?: at a time."
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

We're workin' with an old Mac here, Dave. She might not have a 2-button mouse. That's why I suggested a Cmd-click, or possibly a Ctrl-click.
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

:) this is the world of drop and drag...

I managed to see it on windows 98 IE6.0, when I closed the box it wouldn't come up again. It won't work on Mac IE 5.1.7 would be nice if it did.

Let me know when you can drop and drag surround text or into a parent browser :lol: dreamerrr

maz
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

It could only be the fact you don't have a 2-button mouse, and the old OS and/or browser doesn't recognize a simulation. I have a 2-button on my G4 and it works as advertised.
John
User avatar
Maz
Milonic God
Milonic God
Posts: 1717
Joined: Fri Jun 06, 2003 11:39 pm
Location: San Francisco
Contact:

Post by Maz »

It definately doesn't work on this system even with a three click finger pad on the key board. Its an old Mac/powerPC for translating pc disks.
maz
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi All,

I had made a Milonic conext menu with version 3, 'cause I thought it'd be cool, but abandoned the idea when one of my colleagues complained that it would preclude the standard context menu, which many find useful. I didn't feel like putting in a toggle to enable/disable the custom menu, although in hindsight I suppose it wouldn't be too hard. I still haven't gotten to the production phase of our site using v5, but I do get a chance to dabble now and then, by way of preparation of course (my excuse for playing). And this is just the sort of dabbling I like :)

I imagine Andy's approach probably doesn't involve any special functions in the menu system itself, but is somewhat like most right-click customizations: you trap and handle a right click event; in this case, by opening a menu that's already defined in your menu_data.js file, but not linked to any showmenu call and not alwaysvisible to start.

It was easy to convert my v3 implementation to v5, because the menu system itself does the hard work (e.g., you can just use the built-in popup() function to open the menu at the cursor location). Here is a script that could get you started:

Code: Select all

var mm5_contextMenuName = "contextMenu";

function mm5_showContextMenu()
{
  popup(mm5_contextMenuName, 1);
  return false; // disables the standard context menu;
}

function mm5_hideContextMenu()
{
  menuObj = gmobj("menu" + getMenuByName(mm5_contextMenuName));
  menuObj.style.visibility = "hidden";
}

document.oncontextmenu = mm5_showContextMenu;
document.body.onclick = mm5_hideContextMenu;
Copy the code into the top of your menu_data.js file, or put it in a separate .js file that you load into each page that you want to display context menus (the first way is easier in my book).

The gloabal variable at the top, mm5_contextMenuName, should be set to the name of the menu that you want to open when the user right clicks. That menu should be defined in your menu_data.js file, just as you would define any other submenu (but this one isn't opened by a showmenu call from any other menu).

That's it. When you right-click on the page, the menu will open at your cursor location (the popup() function in the menu system does all the work, including adjusting for collisions with window edges). If you left-click anywhere off the menu, the menu should close. Or, if you mouse over the menu, then out again, the menu should close. The latter behavior could be modified, so that the user had to click off of the menu to close it -- like the standard Windows context menu. You'd do this by setting alwaysvisible to on, but you'd have to do it programatically, at run time, rather than in the menu_data definition, so that the menu didn't appear automatically when the page first loads (it would actually be an easier tweak than it sounds!).

One catch... this code isn't written to work with ns4. But if anyone wants to make it work with ns4, and doesn't know how, give a holler and I'll make the necessary adjustments. Hope some of you find it useful.

Gearing up for menuing madness!...

Kevin
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

'Bout time you got back in here, bub! Where the heck have you been?

Thanks for the code snip.
John
User avatar
kevin3442
Milonic God
Milonic God
Posts: 2460
Joined: Sat Sep 07, 2002 12:09 am
Location: Lincoln, NE
Contact:

Post by kevin3442 »

Hi John,

Been swamped with work... traveling the country teaching good guys devious ways to nab bad guys, then catching up on the work that piles up while I'm gone. Haven't had much chance to work with the new menus. But we just released our latest product upgrades, so a major website overhaul is imminent. I'll need to play... uh... research and experiment with the menus to prepare for that! Looks like you and Dave have the boards well covered. You two are doing an excellent job, along with a few of your regular participants. You're all due a big Thanks! This is still one of the best on-line communities I've ever come across. Keep it up, please, because I'll probably be hammering you with questions in due course! ;) (And probably chime in now and then to give back).

Keep up the excellent work!

Kevin
User avatar
John
 Team
 Team
Posts: 5967
Joined: Sun May 19, 2002 8:23 pm
Location: Phoenix, AZ
Contact:

Post by John »

Thanks very much for the kind words - most appreciated.

Keep your eye on the updates (not all are posted in a message). Andy has been pumping them out pretty fast. You will like this v5. More features than you can shake the proverbial stick at.

Play with it, and please jump in (as you have been) at any time. Your expertise is welcome, as always.
John
Post Reply