callback
The command procedure to be executed when a mouse wheel is scrolled within the contents area of a window during menu polling. The window identifier and 2 other numeric values are passed to the procedure as parameters.
If we consider a mouse wheel to be a full circle, then an operation of the wheel, i.e. a scroll up or down, can be considered as a movement in degrees. Most mouse wheels are notched, with a single movement of the notch yielding a vlue of 15 degrees. A scroll up (away from the operator) is treated as a positive movement, a scroll down (toward the operator) is treated as a negative movement. When a movement includes multiple notches, the notch value are added together producing a composite value. A multiple notch movement is terminated after 200 milliseconds inactivity.
The 2 numeric parameters passed to window.wheel are: the composite notch value, and a "keyboard modifiers" value indicating whether the Shift or Control keys were pressed at the same time, e.g.
0 - Neither Shift nor Control key was pressed
1 - The Shift key was pressed
2 - The Control key was pressed
3 - The Shift and Control keys were pressed
Within this procedure, any command or function which normally requires an interactive mouse action from the user will return with the current mouse position without requiring the operator to use the mouse.
New windows have a .wheel procedure of null.
window.wheel (<window>,<delta>,<kb_modifiers>)
Create a graphic window and use the mouse wheel as a zoom in/out mechanism.
window gw = wgraphic -bc=grey box; plan; grid -ord,-ongw.wheel = { args gw=window, delta=numeric, modifiers=numeric # Plan views only if (gw.view != 6) { !View must be plan; return } # Get the current window corners point corns[] = gw.corners numeric w = corns[2].x - corns[1].x numeric h = corns[2].y - corns[1].y # Get the number of wheel notches pressed numeric notches = delta/15 # Each notch of the mouse wheel is 15 degrees # Use each notch to zoom in/out by 10% # or 25% if the Shift key is pressed # or 50% if the Control Key is pressed numeric perc = 10 if (modifiers > 1) { perc = 50 } else if (modifiers) { perc = 25 } # Adjust the window corners w *= 0.5 * notches * perc / 100 corns[1].x -= w corns[2].x += w h *= 0.5 * notches * perc / 100 corns[1].y -= h corns[2].y += h # Repaint at the new scale gw.corners = corns }