Mouse Position

BlitzPlus Forums/BlitzPlus Programming/Mouse Position

Mental Image(Posted 2007) [#1]
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.


CS_TBL(Posted 2007) [#2]
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)


Mental Image(Posted 2007) [#3]
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.


CS_TBL(Posted 2007) [#4]
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 - ..!


Mental Image(Posted 2007) [#5]
Thanks, CS_TBL, no need for an example, I have got it now. Help much appreciated.


Mental Image(Posted 2007) [#6]
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!