Saturday, February 19, 2011

JavaScript: onMouseOver Event Not Working Properly With Other Events

Programmer Question

Hello,



I have a HTML webpage that contains a 15x15 table and I also have a small square div that follows the mouse when you press and hold the left mouse button on the div.



I have assigned an onmouseover event to the 15x15 table so that when the mouse hovers over a cell, a variable called "gridPlacement" is set the value of the unique id of the table cell the mouse hovered over.



The onmouseover event seems to work fine and instantly as soon as you hover over a cell the variable "gridPlacement" is set to the cell's id.



But when the onmousedown and onmousemove events are triggered (when the mouse presses and holds the left mouse button on the div I mentioned earlier), sometimes when you hover over a cell the variable "gridPlacement" isn't set, and sometimes you have to move your mouse over the cell a few times for it to work.



It seems the onmousedown and onmousemove events seem to have an impact on the onhover event on my 15x15 table.



Does anybody know why this happens and how I can work around this problem?



I hope you understand me, I've tried to explain my problem as best as I can.



Find the answer here

How can I detect window destruction from the main thread?

Programmer Question

Typically, the window procedure for a "main" window class would call PostQuitMessage in response to a WM_DESTROY message.



I would prefer to have the main thread decide when it wants to terminate based on the lifespan of the window(s) it creates. This way, whatever window class I choose to be the main window can have a generic window procedure that doesn't have PostQuitMessage in it.



while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);

if(msg.hwnd == hWnd && msg.message == WM_DESTROY)
{
PostQuitMessage(0);
}
}


The above is my attempt, but the WM_DESTROY message is never posted to the message queue, it seems to be internal to the window procedure.



Is there some way to accomplish this?



Find the answer here

Backbone.js versus Express versus Ext JS ...and JSPP?

Programmer Question

What are the pros and cons of Backbone.js, Express, Ext JS, and JSPP??



Find the answer here

LinkWithin

Related Posts with Thumbnails