![]() Update the mouse co-ordinates when moved Define some variables to keep track of the mouse status We’ll also use our own getMousePos function to get the current co-ordinates of the mouse pointer when it’s moved. Let’s call them sketchpad_mouseDown, sketchpad_mouseUp and sketchpad_mouseMove. So we should have one function for each event. What each handler will do is simply call a function of our choice immediately after the event is triggered. Nothing happens – We will need to add event handlers to tell the browser to do something when that specific event is triggered. So, we will need to keep track of the mouse button status by using the mouseup and mousedown triggers.Īdditionally, we can use mousemove to do something useful when the mouse is being moved. mousemove event – Activated each time that the mouse is being moved, regardless of the button state.mouseup event – Activated once whenever the (left) mouse button is released.mousedown event – Activated once whenever the (left) mouse button is pressed.In fact, we have 3 useful triggers or “events” to help us keep track of the mouse: ![]() We have to keep track of when the button is pressed and released ourselves, in order to determine whether it’s currently being held down. There is a slight complication here, since we can’t directly check if the mouse button is being held down using Javascript.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |