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:07
offfunction event query
Poster: Phil
Dated: Thursday October 7 2004 - 10:58:36 BST
Hi,
It appears that the menu item offfunction event only fires when the mouse, on leaving the relevant item, moves over another menu item or menu (or some other part of the milonic menu hierarchy) - but it does NOT fire if it's next move is off any of this - ie over the underlying page body.
Somehow the menu as a whole recognises when this happens (otherwise submenus wouldn't close as they do with keepalive=0) but yet offfunction isn't fired. Is there a global "offmenu" event I've missed?
Is this an insurmountable problem? It is kind of a nuisance, as it means I can't guarantee that my onfunction happenings aren't undone by my offfunction, depending on how the user moves his/her mouse....
cheers
Phil
Poster: Ruth
Dated: Thursday October 7 2004 - 17:01:11 BST
Could you post a test page to see what's happening? This allows us to see your html code and menu_data coding.
Ruth
offfunction
Poster: Phil
Dated: Thursday October 7 2004 - 17:36:09 BST
OK, go to
http://www.nsead.org/m4/index.asp
First off, let me apologise for the ghastly colours and poor graphics! I am waiting for the designers to finish their job, meanwhile trying to get the functionalty working!
Don't click any links - they won't work.
The problem then is this:
As you move the mouse over the main menu, an "offfunction" function changes the logo on the left to match the colour of the submenu. This is fine.
Do this: move the mouse off the main menu by sliding it down off the bottom (below Special Projects) - the main logo reverts to it's native state, because the last (blank) menu item has an onfuction event that does this.
But, if you move the mouse off the menu by sliding it up and off over the top About Us item, or to the left over the main logo, or by sliding it right and right across the submenu and out the other side, then it doesn't - even though all these (sub and main) menu items have the appropriate offfunction defined, it doesn't get called when the mouse leaves the menu area.
(I note that if the mouse is moved too quickly the same problem occurs - though even so the menu seems to know that the mouse has gone because any sub menu disappears, so there must nbe an event I can capture?)
Do you need to see the .inc files?
Thanks - I have a sort of acceptable alternative which I quite like at
http://www.nsead.org/m7/index.asp
but this keeps the submenu open until the user clicks the page to revert to the original.... it would be nice to sort out the original roblem.
cheers
Phil
Poster: Ruth
Dated: Thursday October 7 2004 - 19:48:09 BST
Hi Phil,
My usual disclaimer: I am not a function/progammer/coding person. Do you need an offfunction, also, or a restoreImage or something making it restore the main logo as you mouseOff? I also like the last page. Maybe there could be a way to have what you have there and write a function to close the submenu when you mouseout? I don't know what you did differently as to functions to get it to do what it is doing.
Ruth
mouseOff
Poster: Phil
Dated: Thursday October 7 2004 - 20:11:27 BST
Hi Ruth,
but that's my problem: there is already a mouseOff function (the menu item 'property' called offfunction) that is supposed to fire whenever the mouse leaves a menu item - trouble is, it doesn't, unless the mouse stays over another part of the menu (ie moves over another menu item) This is why the image and colours don't change when the mouse leaves the menu altogether and goes over the page body.
Somehow though the whole menu *does* know when this happens, because the submenus collapse (they don't on my second page becasue I've set keepalive=1 but they would otherwise), but despite this the offfunction event doesn't fire. It should - it really should!
cheers
Phil
Poster: Maz
Dated: Thursday October 7 2004 - 20:28:17 BST
Just my opinion, I like what it does, but since it doesn't link yet I can't tell what happens next, then using pagematch to show where you are color, unless you want it to return to the original color. I'm not sure if pagematch would help with what you want to do.
I was just contemplating menu color mouseover.
A js team member will pop in before long.
maz
Poster: Ruth
Dated: Thursday October 7 2004 - 22:57:28 BST
I have a heck of a time trying to express things since I don't have the terminology and stuff. You are calling the swap image function in all the aI strings each string putting in a different image, but you do not have an restore image function. So, it seems to me what the menu is doing is to initiate the function and swap the logo image. But, when you mouseout it never gets an offfunction to tell it to get rid of the swapped image. That doesn't matter when you move from one item to the next because there is another 'image' to swap. I do not know how the menu does the on/off functions, but it would seem that if you have an onfunction if you want the menu to stop using it you need to tell it to do that. Right now when you move off the menu, it doesn't get a message telling it to swap the image back to the original logo and to stop using onfunction.
If this is the case, it would mean that since you cannot control which item the person will start onMouseover nor which item it will end and finally mouse off the menu, I would think you have to tell it to restore the original image in each of the aI strings. That's how it seems to be working to me.
I do not know if you could create some kind of function that told the mouse if you are on the page other than on the Milonic menu, make the logo the nsead image.
Ruth
offfunction
Poster: Phil
Dated: Thursday October 7 2004 - 23:31:23 BST
mm thanks - my point is it doesn't make any difference as the offfunction doesn't fire when the mouse is moved off the menu. Just to prove it I've explicitly put ti back in (as you suggest - though I have tried this before) so you can see for yourself that the problem persists.
There is a rather un satisfactory workaround - more or less along the lines you suggest - of placing transparent gif images below the menu with an onmouseover function to restore the original logo, but...
And I still would like to know how the menu knows that the mouse has left it - and I know it knows because it collapses submenus as soon as that happens - but it won't tell me so I can do my thing too! (sulk)
cheers
Phil
Poster: Ruth
Dated: Friday October 8 2004 - 3:58:58 BST
Sorry, I couldn't help. There is a volunteer who knows functions but I believe he's away this week. I still think it has to do with the offfunction. I know if you have this on a page for example
Code:
<A
onmouseover="MM_swapImage('image1,'','image2.gif',1)" href="http://whatever"><IMG height=227 src="image1.gif" name=image1></A>
when you mouseover you get image2.gif and when you mouseout it stays at image2.gif. In order to go back to the image1.gif you need to have onmouseout=MM_swapImgRestore() in that code. onmouseover="MM_swapImage('image1,'','image2.gif',1)" href="http://whatever"><IMG height=227 src="image1.gif" name=image1></A>
A function was written for me to swap text in the menu, in the item it's coded to call the function as:
Code:
onfunction=mm_changeItemProperty('Main Menu','Hello',1,'Welcome',1);
onMouseOver Hello switches to Welcome. But, if I do not also code offfunction= and the same thing but swithing the position of Hello and Welcome it will remain at Welcome until the page is refreshed. I'll post for the function person and hopefully when he gets back he can help.
As to the mouseoff of the menu and closing the submenu that's in the programming and I would have no idea where in all that 'goobledy gook' it would be, besides which this is not open source so you are not allowed to modify the actual programming.
Ruth
mouseoff
Poster: Phil
Dated: Friday October 8 2004 - 10:46:33 BST
Hi, well thanks for your efforts and, while I have the oportunity, thanks to all of you for what is a very very good product - I am well impressed. And I wouldn't dream of altering your copyright code - was just hoping that there was a public function (programming parlance) somewhere that I had missed that would let me know when the mouse had left the menu so that I could fire my own imageSwap funxction. Nevermind, I'm sure I can work around the alternative solution I came up with. Thanks again. Phil
Poster: kevin3442
Dated: Tuesday October 12 2004 - 0:58:15 BST
Hi Phil,
I'm a little late to the game... wondering if you're still working on this or still want input? I've never had a problem with the offfunction firing. Willing to take a look if you're still at it.
Kevin
Poster: Phil
Dated: Tuesday October 12 2004 - 11:37:22 BST
thanks - well, yes, but am avoiding the problem for now as I can't solve it - if you/we can then so much the better... have you understood the root of the problem from what's been said so far?
cheers
Phil
Poster: kevin3442
Dated: Tuesday October 12 2004 - 18:05:28 BST
Hi Phil,
Phil wrote:
have you understood the root of the problem from what's been said so far?
I believe so. When the pointer traverses main menu items, from one to the next, the offfunction is indeed firing (as you've no doubt seen in your testing). One doesn't really observe that fact, sine the next item's onfunction fires immediately following (so you never really see the logo revert to its default). But as you've observed, when the mouse exits the main menu altogether, the offfunction is not firing.
I think the problem boils down to a timing issue. In your menu_styles.js file, you have set _menuCloseDelay=10. It seems that this delay is also involved in the firing (or not) of the offfunction. It looks like 10 milliseconds isn't enough time for the offfunction to fire. Try bumping that value up until you get reliable firing (I ended up at 100 in some quick testing).
Cheers,
Kevin
Poster: Phil
Dated: Tuesday October 12 2004 - 23:24:54 BST
thanks for the try - but doesn't do the trick - I have bumped it right up to 1000 ( so you can clearly see the delay before the submenus close) but the offfunction to swap the main menu back still isn't firing when you exit the menu system. Odd - I should say that the designers have settled on a slightly different idea now so this problem doesn't have to be solved - so don't spend precious time on it, though it would still be interesting to know what's going on....
cheers
Phil
Poster: kevin3442
Dated: Thursday October 14 2004 - 23:25:50 BST
Hi Phil,
I forgot to mention that I had also taken your main menu out of the table and put it with the rest in menu_data.js, positioning it with the top and left properties (also removing position = "relative"). I did this first, thinking that embedding it in a table might have something to do with the phenomenon, only to discover the _menuCloseDelay issue later. After I found the delay issue, I never put the menu back in the tabl;e to test it. Out of curiosity, I just put the main menu back in the table, and the offfunction, which had been working, stopped working. So, it appears to be related to both issues: taking the main menu out of the table and bumbing up the _menuCloseDelay makes the offfunction work. No idea why the table is involved.
Just FYI.
Kevin
Looks like this is still a problem a year later...
Poster: jswick
Dated: Friday December 16 2005 - 18:45:42 GMT
I was experiencing the same problem with the offfunction not firing. I was hoping since this thread started a year ago, that someone has found a fix. I have an example here: http://www.slickswick.com/milonic/index.htm I have three menus, two of them are actually only being used for navigation of the middle menu. When you move the mouse off of the navigation menu's the function specified in the offfunction to stop the middle menu from scrolling is not fired. You have to see the menu's to understand.