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
WINDEV
WindowsLinuxJavaReports and QueriesUser code (UMC)
WEBDEV
WindowsLinuxPHPWEBDEV - Browser code
WINDEV Mobile
AndroidAndroid Widget iPhone/iPadIOS WidgetApple WatchMac Catalyst
Others
Stored procedures
MouseXPos (Function)
In french: SourisPosX
Used in a mouse or stylus event (click code, hover code, left or right button pressed code, etc.) returns the horizontal position (X) of the mouse cursor in relation to the field 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).
Remarks:
  • Android This function should only be used in the events of controls hovered with the mouse.
  • Android MouseXPos returns the last known position of the finger on the screen.
Example
AndroidiPhone/iPadIOS WidgetMac Catalyst
// Affiche un message différent selon l'endroit cliqué
IF MouseXPos() > 25 THEN
	Info("A droite")
ELSE
	Info("A gauche")
END
Syntax
AndroidiPhone/iPadIOS WidgetMac Catalyst

Retrieving the mouse position in a window Hide the details

<Result> = MouseXPos([<Origine>])
<Result>: Integer
  • Horizontal position (X-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 to calculate position:
mpControl
(Default value)
Mouse position relative to the upper-left corner of the hovered control or window, depending on where the event occurs.
mpImageMouse position in the Image control (relative to the upper-left corner).

This constant should only be used when MouseXPos is called in an event associated with an Image control. Otherwise, MouseXPos 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.
Remarks
AndroidiPhone/iPadIOS WidgetMac Catalyst

Error

The main error codes are as follows:
  • No window is opened.
  • No mouse click is performed.
  • MouseXPos is not called in a mouse event.
  • The click code is executed by Execute or ExecuteProcess.
AndroidiPhone/iPadIOS WidgetMac Catalyst

Miscellaneous

  • You can get the vertical position of the mouse or stylus with MouseYPos.
  • MouseXPos used in the selection code of row or table always returns 0.
  • Android This function should only be used in WLanguage events of controls hovered with the mouse.
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: wd300obj.dll
Minimum version required
  • Version 9
This page is also available for…
Comments
Click [Add] to post a comment

Last update: 09/14/2024

Send a report | Local help