Project

General

Profile

Mouse Position Location

FWD provides an extension to the 4GL language to allow to retrieve the actual mouse cursor position. This is in the form of a new method GET-MOUSE-POSITION. The method is available in every UI widget and returns the coordinates of the actual mouse cursor position relative to the widget origin. When the method is invoked on a WINDOW widget the method returns the coordinates relative to the client window area, that is the "drawing area" of the window which excludes the title bar, "decorations" and borders. The function returns an integer extent of 2 where the value at index 1 denotes the X pixel coordinate and the value at index 2 denotes the Y pixel coordinate. The method is only supported in GUI mode, in ChUI both coordinate values are set to 0.

Example:

DEF BUTTON  btn LABEL "this is a button".
DISPLAY btn AT COL 10 ROW 5 WITH FRAME f SIZE 40 by 10.
DEF VAR loc AS INT EXTENT 2.
ON "i" ANYWHERE
DO:
    loc = DEFAULT-WINDOW:GET-MOUSE-POSITION().
    MESSAGE "Cursor position relative to window client area x:" loc[1] "y:" loc[2].
    loc = btn:GET-MOUSE-POSITION().
    MESSAGE "Cursor position relative to the button origin x:" loc[1] "y:" loc[2].
END.
WAIT-FOR CLOSE OF THIS-PROCEDURE.


© 2004-2017 Golden Code Development Corporation. ALL RIGHTS RESERVED.