Varying _subOffsetLeft for multiple sub levels

Having problems with DHTML Menu? There is usually somebody here who knows the answer.
Post Reply
JayZee
Beginner
Beginner
Posts: 2
Joined: Mon Feb 28, 2005 5:18 am
Location: Crystal Lake, IL

Varying _subOffsetLeft for multiple sub levels

Post by JayZee »

The main menu is vertical, with two sub menu levels. Is it possible to create a different left offset value for each sub level? Thank you.
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 JayZee,

It's not possible using _subOffsetLeft, because that's a global variable. However, you could do it like this:

(1) Define another global variable at the top of menu_data.js, like:

Code: Select all

subLeftOffset=10;
Set the value (e.g., 10 above) to however many pixels you want to use for the additional offset. You can use a negative value to offset the position to the left, or a positive value to offset to the right.

(2) For any submenu where you want to apply the additional offset, put the following code in the menu definition:

Code: Select all

left="offset="+subLeftOffset;
So, the menu definition would look something like this:

Code: Select all

with(milonic=new menuname("Menu Name")){
style=menuStyle;
left="offset="+subLeftOffset;
aI("text=Item Text;url=theurl.htm;");
...
}
The reason you'd use a variable, rather than just putting left="offset=10"; in each affected menu definition is that using a variable makes it easier to change later. For example, suppose you edited 15 submenus, then decided that 10 wasn't the right value. Rather than re-editing all 15 submenus, you'd just change the value assigned to subLeftOffset at the top, which would adjust all of the submenus using that variable.

A couple of last notes: (1) If you don't use subLeftOffset in a submenu, it will still use the default _subOffsetLeft value. (2) The offset applied by the new subLeftOffset variable is in addition to the offset provided by _subOffsetLeft; they are cumulative.

Hope that helps,

Kevin
JayZee
Beginner
Beginner
Posts: 2
Joined: Mon Feb 28, 2005 5:18 am
Location: Crystal Lake, IL

Post by JayZee »

Kevin,
Thanks for the solution. It works great! Just for good measure I applied the same approach to the top offset with equally good results. It is very helpful to have an adjustment like this in the Milonic toolkit.

Your description and walkthrough were thorough, and it all made sense to a novice like me.

This forum is what convinced me to buy a license. Milonic has a very active support team, and I appreciate your rapid assistance.

JayZee
Post Reply