Hi,

I hope this is the right forum for this question...
I am using Chrome Dev 4.0.249.25.

I am creating a small floating menu and I want to detect when someone
clicks outside of it. The way I detect if someone clicks out of the
menu is by registering a window click event (window.addEvent...
('click')) and I test if event.target is equal to the original menu
object (or a child of it). This worked on the Chrome beta version
that
I previously installed, but now with the dev version I see that the
event is not the original event element but some type of copy that no
longer validates with a (event.target == paramElement).

sample code:
//creating menu:
var menu = document.createElement('div');
myAddChildren(menu);
window.addEventListener('click', function(event) { removeMenu(event,
menu); }, false);
document.body.appendChild(menu);

//removing menu:
function removeMenu(event, menu) {
 //event.target is never equal to menu even when it should be!!!
if((event.target == menu) || (myIsChild(menu, event.target)))
 return //don't remove if click is on menu itself or a child of menu
window.removeEventListener('click', arguments.callee.caller, false);
document.body.removeChild(menu);

I also noticed that if I add a custom variable to the menu object it
doesn't show up under event.target when clicked. I have also verified
that the element clicked is the actual menu as opposed to a child. I
can verify this via the className which is set to the menu class type.
The test that previously passed and *** should *** pass is
(event.target == menu).

The effect is that I want the menu to stay open so long as I've not
clicked out of it. A click inside of it should keep it open. I know
this sounds strange and it's not the way it will be in the end, but
it's important for now.

Thanx,
nachum

-- 
Chromium Developers mailing list: chromium-dev@googlegroups.com 
View archives, change email options, or unsubscribe: 
    http://groups.google.com/group/chromium-dev

Reply via email to