Click to See Complete Forum and Search --> : Stopping mouseover event


marek_walford
02-19-2003, 05:34 AM
Hi,

I have a series of listboxes which are positioned "absolute" i.e. on top of other controls. If the scrollbar on the list box is scrolled the controls underneath fire mouseover events (even though they are hidden under the listbox). Does anybody know how to stop them firing? I need control to remain within the listbox.

Many thanks,
Marek Walford

marek_walford
02-19-2003, 08:07 AM
Thanks for the reply. Trouble is I have a "onmouseout" event on the SELECT and this event fires when the mouse moves over the elements hidden under the SELECT. I want it to fire when the mouse moves out of the SELECT but it fires when the mouse is still within the SELECT but over an element underneath.

Cheers,
Marek

russ_man7
02-19-2003, 06:33 PM
i don't think your problem is so much that the other elements steal your mouse event, as much as JS thinks that mousing over the choices means you have moused out of the select box itself. try a blank page with just a select element, and give that select an onmouseout event. you may see that it loads that event when you move your mouse into the options; at least it does in IE6. you may want to explore other options, maybe using onblur instead of onmouseout.

marek_walford
02-20-2003, 04:25 AM
Hi,

Below is an example, I've removed as much of the code as possible so it demonstrates the problem and nothing else:

Click on the image (you won't have the image but it will still work) at the right-hand end of the first combo box (a list will pop up). Scroll down the list and look at the IE status text. It will write text everytime the SELECT mouseout fires. You can see that this event fires every time the pointer passes over one of the other images hidden underneath. As the pointer hasn't moved out of the SELECT I wouldn't expect the eventto fire. I can't see why it is! Hope somebody can help.

Many thanks,
Marek


<html>
<head>
<script language="JavaScript">

function ComboBox(name, items, value, width)
{
this.name = name;
this.width = width;

document.write("<div id='" + name + "'>");
document.write("<div>");
document.write("<input style='width:" + width + "px'>");
document.write("<img id='img" + name + "' src='graphics/dropdownbutton.gif' style='position:relative;top:3px;left:-2px' onclick='" + name + ".button_onclick();'>");
document.write("</div>");
document.write("<div style='position:absolute;display:none'>");
document.write("<select id='cbo" + name + "' size='10' onmouseover='" + name + ".combo_onmouseover();' onmouseout='" + name + ".combo_onmouseout();'>");

for(var i = 0; i < items.length; i++)
{
document.write("<option value='" + items[i] + "'");

if(items[i] == value)
{
document.write(" selected");
}

document.write(">" + items[i]);
}

document.write("</select>");
document.write("</div>");
document.write("</div>");

this.combobox = document.getElementById("cbo" + this.name);
this.button_onclick = button_onclick;
this.combo_onmouseover = combo_onmouseover;
this.combo_onmouseout = combo_onmouseout;
}

function combo_onmouseout()
{
window.status = event.srcElement.id + " SELECT mouseout event fired!";
}

function combo_onmouseover()
{
window.status="";
}

function button_onclick()
{
this.combobox.style.width = 315;
this.combobox.parentElement.style.display = "block";
this.combobox.focus();
}

</script>
<body>

<script language="JavaScript">

var items = new Array("a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z");

var combo1 = new ComboBox("combo1", items, "a", 300);
var combo2 = new ComboBox("combo2", items, "b", 300);
var combo3 = new ComboBox("combo3", items, "c", 300);
var combo4 = new ComboBox("combo4", items, "d", 300);

</script>

</body>
</html>

marek_walford
02-24-2003, 04:14 AM
Hi,

I've discovered that the problem lies in the "position:relative" style. If I don't include this style the problem goes away. The "z-index" style apparently doesn't work with window controls (as the SELECT is) so I can't set the ordering. No closer to a solution but at least I know the source of the problem! Any ideas?

Marek