Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

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:16

OnMouseMove and timers conflict


Poster: kexik_white
Dated: Monday September 15 2008 - 13:58:09 BST

I have conflict with menu and AJAX application.
Menu hardly replaces document.OnMouseMove and application doesn't work correctly - you can see example on http://t-mobile.cz/Web/Residential/TarifySluzby/MapaPokrytiCR.aspx - if you switch map application from rezise to move mode (by clicking Image), it doesn't work because menu "steals" event handler.
Is there any mistake in my menu definition or configuration? Or how can I solve this problem?

Second problem is that menu uses timers very agresivelly with low timeout (some of them are 10ms) that causes very slow response of my map application. Is there posibility to change values of these timers?

Thanks.

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Tuesday September 16 2008 - 12:27:28 BST

Hi,

Have you tried declaring the menu as the very first JavaScript object on the page. This will enable anything after the menu code to capture the document.onmousedown event.

With regards to timing, you can try changing the internal settings in the code but it may have adverse effects.

-- Andy

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Thursday September 18 2008 - 14:25:41 BST

Thank you for the answer, I have tried declaring the menu as the very first JavaScript object on the page but it has no impact, problem persists :(

Does the menu use really correct way to attach event handlers?

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Friday September 19 2008 - 10:56:31 BST

Hi,

If the menu has been declared first and then your code is set to capture the document.onmousedown event it will override the menus onmousedown event.

Have you tried removing the menu and seeing if the code works?

Also, try setting your own code for the onmousedown, onmouseup and onclick events and see if that helps.

-- Andy

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Friday September 19 2008 - 13:59:30 BST

Here is example with "very first menu code" - it doesn't work:
http://t-mobile.cz/Web/MapMilonicTest.html

Here is the same page, but drawMenus() is commented - every scripts are loaded, only drawMenus() function is skipped - and map application works:
http://t-mobile.cz/Web/MapMilonicTest2.html

Maybe there is variable name conflict? I cannt imagine what else can be wrong.

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Tuesday September 23 2008 - 14:57:23 BST

I am shure that document.onmousedown is set by the menu function called by timer - thats why it doesnt depend on script order.

I think menu code should assume that somebody other have set document.onmousedown first :(

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Tuesday September 23 2008 - 15:05:21 BST

I can confirm that document.onmousedown is executed only once when the menu is loaded.

This means you can override it.

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Thursday September 25 2008 - 11:51:49 BST

Thank you for your reply. I will try to deactivate URL matching - but I cannt find page with global properties it seems to be missing http://www.milonic.com/global_properties

Is it possible to disable URL matching?

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Thursday September 25 2008 - 11:54:20 BST

You should just be able to remove any reference to "pagematch" within your data file. This will disable pagematching. Unless you mean something other than page matching?

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Monday September 29 2008 - 8:17:38 BST

Andy wrote:
I can confirm that document.onmousedown is executed only once when the menu is loaded.

This means you can override it.


I analysed actions of menu code and found that problem is caused by incorrect setting of document.onmousedown handler.
It is set by only once but by a timer, so It happens after the handler has been set by other scripts.

I can set document.onmousedown later by a timer too but this is a dirty hack.
I would rather not modify original menu code to correct setting of onmousedown handler.

Is there way to correct the menu code by the Milonic?

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Monday September 29 2008 - 13:59:33 BST

Again, I can assure you that the menu does not set a document.onmousedown event through a timer.

If you visit both pages:

http://t-mobile.cz/Web/MapMilonicTest.html
http://t-mobile.cz/Web/MapMilonicTest2.html

Then type the following into your browser address bar for each page you will see the same function (that has nothing to do with Milonic) appear in the alert box.

javascript:alert(document.onmousedown)

Code:
function (e){ev(e);fce(e);}


The above is the function that has control over document.onmousedown, the menus event has been deleted.

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Tuesday September 30 2008 - 11:11:20 BST

I have to apologize - the problem is not with onmousedown handler but with document.onmousemove.

This is set inside $N function called by a timer and this timer is set inside function o$.

The first (affected) page has incorrect handler:

function gMY(e){if(ns6){X_=e.pageX;Y_=e.pageY}else{e=event;X_=e.clientX;Y_=e.clientY}mmMouseMove();_TtM();_IdM();doMenuResize(focusedMenu)}

The second page has different handler:

function(e){ev(e);fce(e);}

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Tuesday September 30 2008 - 11:23:08 BST

In that case, adding the following to your menu_data.js file will disable the menus onmousemove code:

disableMouseMove=true;

Please let me know if this helps or not.

-- Andy

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Tuesday September 30 2008 - 14:12:39 BST

Here is page http://t-mobile.cz/Web/MapMilonicTest.html with disableMouseMove=true;

Map application now works fine - but when the move button is clicked, the menu stops work.

Re: OnMouseMove and timers conflict


Poster: Andy
Dated: Tuesday September 30 2008 - 14:20:27 BST

I don't see any problems with the menu, works fine for me in Firefox and IE6.0

Re: OnMouseMove and timers conflict


Poster: kexik_white
Dated: Thursday October 2 2008 - 14:21:30 BST

Thank you, problem has been fixed - in IE7 was a bug in a map application.