ONLINE HELP
 WINDEVWEBDEV AND WINDEV MOBILE

This content has been translated automatically.  Click here  to view the French version.
Help / WLanguage / WLanguage functions / Standard functions / Windows functions / Mouse functions
  • Error
  • Miscellaneous
  • Limits in browser code
WINDEV
WindowsLinuxUniversal Windows 10 AppJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac CatalystUniversal Windows 10 App
Others
Stored procedures
MouseYPos (Function)
In french: SourisPosY
Used in an linked mouse or stylus event (click code, hover code, left or right button pressed code, etc.) returns the vertical position (Y) of the mouse cursor relative to the control or window in question.
You can get:
  • the position of the mouse (or stylus) when an Image control is clicked (function used in the "Click" event of the Image control)
  • the position of the mouse (or stylus) when hovering over a window (function used in the optional "Mouse hover" event of a window)
WEBDEV - Browser code Used in a browser event (of an control or Page), returns the vertical position (Y) of the mouse cursor according to the specified origin.
Remarks:
  • WINDEV The mouse position can also be obtained with CursorPos. CursorPos should only be used to modify the mouse position.
  • Universal Windows 10 AppAndroidJava This function should only be used in the events of controls hovered with the mouse.
  • Universal Windows 10 AppAndroid MouseYPos returns the last known position of the finger on the screen.
Example
WINDEVReports and QueriesJavaUser code (UMC)
// Survol souris de la fenêtre "FEN_Dessin"
// Code optionnel de la fenêtre
Message("Position de la souris : X : "  + MouseXPos() + " Y : " + MouseYPos())
WINDEVReports and QueriesUniversal Windows 10 AppAndroidiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)
// Affiche un message différent selon l'endroit cliqué
IF MouseYPos() < 25 THEN
	Info("En haut")
ELSE
	Info("En bas")
END
WEBDEV - Browser code
// Survol souris de la page "Dessin"
// Code optionnel de la page
// Souris déplacée (onmousemove)
Message("Position de la souris: X: " + MouseXPos(mpPage) + " Y: " + MouseYPos(mpPage))
Syntax
WINDEVReports and QueriesUniversal Windows 10 AppAndroidiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)

Retrieving the mouse position in a window Hide the details

<Result> = MouseYPos([<Origine>])
<Result>: Integer
  • Vertical position (Y-coordinate) of the mouse or stylus, in pixels. By default, this position is relative to the upper-left corner of the control on which the left mouse button was pressed.
  • -1 if an error occurred.
<Origine>: Optional Integer constant
Origin used for position calculation:
mpControl
(Default value)
Mouse position relative to the upper-left corner of the control or window, depending on where the event occurs.
mpImageMouse position in the image (relative to the upper-left corner of the image).

This constant should only be used when MouseYPos is called in an event associated with an Image control. Otherwise, MouseYPos will return -1.
mpScreenMouse position in the screen (relative to the upper-left corner).
mpWindowMouse position relative to the upper-left corner of the window.

Universal Windows 10 App This parameter is not available.
WEBDEV - Browser code

Retrieving the mouse position in a page Hide the details

<Result> = MouseYPos([<Origine>])
<Result>: Integer or real
  • Vertical position (Y-coordinate) of the mouse cursor relative to the specified marker, in pixels,
  • 0 if the information is not available (depending on the browser used and on the control).
<Origine>: Optional integer constant
Indicates the origin used to calculate the position:
mpControl
(Default value)
Mouse position relative to the upper-left corner of the control or page, depending on where the event occurs.
If this constant is selected, MouseYPos must be used in the "OnClick" code of the control.
mpPageMouse position relative to the upper-left corner of the page (taking into account the position of the page if it has been scrolled).
mpScreenMouse position in the screen (relative to the upper-left corner).
Remarks
WINDEVReports and QueriesUniversal Windows 10 AppAndroidiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)

Error

The main error codes are as follows:
  • No window is opened.
  • No mouse click is performed.
  • MouseYPos is not called in a mouse event.
  • The click code is executed by Execute or ExecuteProcess.
WINDEVReports and QueriesUniversal Windows 10 AppAndroidiPhone/iPadIOS WidgetMac CatalystJavaUser code (UMC)

Miscellaneous

  • You can get the horizontal position of the mouse or stylus with MouseXPos.
  • MouseYPos used in the selection code of row or table always returns 0.
WEBDEV - Browser code

Limits in browser code

MouseYPos is not available:
  • in browser procedures.
  • in the events directly or indirectly called from a browser procedure (via ExecuteProcess for example).
Related Examples:
The drawing functions Unit examples (WINDEV): The drawing functions
[ + ] Using the main drawing functions of WINDEV to:
- Initialize an Image control for drawing
- Draw simple shapes
- Write a text into a drawing
- Change the color in a drawing
Component: wd290obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 04/09/2024

Send a report | Local help