Mouse Position
BlitzPlus Forums/BlitzPlus Programming/Mouse Position
| ||
I am developing an application that has a vertically scrolling canvas (controlled by a slider) within a panel on my main form. The following constants are used by the program: PanelX ; x position of panel within window PanelY ; y position of panel within window PanelWidth ; width of the container panel PanelHeight ; height of the container panel CanvasHeight ;height of teh scrolling canvas I would like to know the mouse position relative to the CANVAS at any time (so that I can have rollover tool tips), but am crap at maths. Any suggestions gratefully received. |
| ||
Is this rollover tool tip the only thing you want with those coords? (e.g., you hoover the mouse over the canvas, and immediately or after a while a tooltip comes) |
| ||
Well, sort of, but there would be different tooltips depending on what part of the canvas was in view. If you imagine that the canvas contains five vertical grids, and each grid portion corresponds to an array position. As the mouse hovers over each grid position, if the corresponding array is not zero, a tooltip would be generated. To behonest, I can work it out relative to screen positions, but it is the scrolling canvas that throws me. I am scrolling the canvas with SETGADGETSHAPE (from a tutorial on here) so I can't find the absolute vertical position of the canvas within the panel at any time. |
| ||
Well, a simple calculation involving EventY() on the canvas, and the scroll offset of the canvas (given by that slider) would do. I'm a bit busy atm to 'examplify' this.. :P But you need EventY() and that slider-position.. try some + and - ..! |
| ||
Thanks, CS_TBL, no need for an example, I have got it now. Help much appreciated. |
| ||
Just as a matter of interest, I have used MouseX(canvas) and MouseY(canvas) and activated the tool tip by clicking. Being able to see where the mouse is relative to any point on a canvas is incredibly useful (especially for scrolling canvasses). Way cool! |