...

View Full Version : Onscroll and componentFromPoint bugs



WMJB
03-17-2005, 02:52 AM
I am trying to capture the onscroll event so that I can record what button or area a user clicked on a particular scrollbar.

There are two problems that are giving me grief.

1. The onscroll event fires ~40 times each time a scrollup or scrolldown button is pressed. This causes my onscroll= function to run over and over again where I only want it to run once!

2. The componentFromPoint() method returns the value from AFTER the scroll has taken place. So, if you click in the scrollbars track, immediately below the slider (or thumb) you are returned the value "scrollbarVThumb" instead of "scrollbarpagedown".

These two errors combined produce a very annoying effect. Check it out with the following sample HTML. Try clicking on the scrollbar, you have to click a few times to get rid of the alert box. (Or hold down the esc key).

<HTML>
<head>
<script>
function sayCheese(obj)
{
sElem = obj.componentFromPoint(event.clientX,event.clientY);
alert(sElem);
}
</script>
</head>
<body>
<div style="overflow: hidden;" style="height: 300; width: 20" >
<div id="divy" style="overflow-y: scroll;width:0;height:300;" onScroll="sayCheese(this);">
<div style="height: 1000px;width:1;">
</div>
</div>
</div>
</body>
</html>

Thanks guys.

W.

"It doesn't matter if I'm optomistic or not, nothing ever works out for me."

codegoboom
03-17-2005, 12:54 PM
I am trying to capture the onscroll event so that I can record what button or area a user clicked on a particular scrollbar.
Why? :D

WMJB
03-18-2005, 01:13 AM
Believe it or not I am trying to emulate a fake scrollbar. But I want the fake scrollbar to look exactly like a real scrollbar :) (Its a long story)

codegoboom
03-18-2005, 02:07 AM
OK, but to determine the point of mouse capture, would onmousedown not be sufficient?

WMJB
03-18-2005, 02:54 AM
Yes, if I can calculate the exact size and position of the slider. The problem with this is that the slider's height is dependant on your control panel settings!

codegoboom
03-18-2005, 03:01 AM
Perhaps you should summarize this long story...

WMJB
03-18-2005, 03:37 AM
Its ok. I am going to assume that if scrollTop changes by more than 10px and I am returned scrollbarVthumb then it was a pagedown. Then I just ignore the next 100 events. Its not great but it will have to do. I may have to make the 10px a variable depending on the length of the scrollbar.. not sure yet.

Thanks for your help.

W.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum