krycek
11-06-2002, 04:57 PM
I have a widget that I have made, which is a custom scroll box. Basically, it consists of a layer and a scrollbar. I have added an onMouseWheel() event to it so that I can scroll the layer with my mouse wheel, without having to use the scrollbar - just like if you have your mouse over an IE window :)
The desired effect is for the function to be called whenever the mouse wheel is turned and the mouse is over the layer. However, I do not want to manually calculate the position of the mouse in respect to the layer, because I have purposefully stayed away from that, instead using the event.srcElement property.
What actually happens at the moment is that the layer scrolls fine - providing there is nothing "in the way". Now, if I have two layers and one is partly obscuring the one I want to scroll, then this is not a problem. In fact, it is desired behaviour. The problem is with the scrolling layer's children.
I want the layer to scroll if the mouse is over the scrolling layer or it's children, if you see what I mean. The layer will be clipped so none of it's children will be outside of the parent (well, at least not to our intents and purposes here).
I am pretty sure that what I am looking for is to do with event bubbling and the inheritance of the layers/objects. As far as I can tell, a mouseover event on a child should also trigger the mouseover event of the parent, is that correct? Assuming here that cancelBubble has not been used.
I have three levels of mouse handling (a global mouse handler, individual mouse handlers, and a default action - called in that order) which somewhere along the line may be cancelling the event - but before I look through every line looking for something which may not be there, I would like to know if I am on the right track! :D
Any thoughts on this...?
::] krycek [::
The desired effect is for the function to be called whenever the mouse wheel is turned and the mouse is over the layer. However, I do not want to manually calculate the position of the mouse in respect to the layer, because I have purposefully stayed away from that, instead using the event.srcElement property.
What actually happens at the moment is that the layer scrolls fine - providing there is nothing "in the way". Now, if I have two layers and one is partly obscuring the one I want to scroll, then this is not a problem. In fact, it is desired behaviour. The problem is with the scrolling layer's children.
I want the layer to scroll if the mouse is over the scrolling layer or it's children, if you see what I mean. The layer will be clipped so none of it's children will be outside of the parent (well, at least not to our intents and purposes here).
I am pretty sure that what I am looking for is to do with event bubbling and the inheritance of the layers/objects. As far as I can tell, a mouseover event on a child should also trigger the mouseover event of the parent, is that correct? Assuming here that cancelBubble has not been used.
I have three levels of mouse handling (a global mouse handler, individual mouse handlers, and a default action - called in that order) which somewhere along the line may be cancelling the event - but before I look through every line looking for something which may not be there, I would like to know if I am on the right track! :D
Any thoughts on this...?
::] krycek [::