## 7 Mouse Interaction ¶

`(window-get-point w)`
`(window-get-crosshairs w)`
`(window-get-cross w)`
These functions get a point position by mouse click; they return `(x y)` .

The following function gets a point position by mouse click. It returns `(button (x y))` where `button` is `1` for the left button, `2` for middle, `3` for right.

`(window-get-click w)`
The following function gets a point position by mouse click within a specified region. It returns `(button (x y))` or `NIL` if the mouse leaves the region. If `boxflg` is `t`, a box will be drawn outside the region while the mouse is being tracked.

`(window-track-mouse-in-region w x y sizex sizey &optional boxflg)`
The following functions get a point position indicated by drawing a line from a specified origin position to the cursor position; they return `(x y)` at the cursor position when a mouse button is clicked. The `latex` version restricts the slope of the line to be a slope that LaTeX can draw; if `flg` is non-`nil`, the slope is restricted to be a LaTeX `vector` slope.

`(window-get-line-position w orgx orgy)`
`(window-get-latex-position w orgx orgy flg)`
The following function gets a position by moving a “ghost” icon, defined by the icon drawing function `fn`. This allows exact positioning of an object by the user.

`(window-get-icon-position w fn args &optional (dx 0) (dy 0))`
The function `fn` has arguments `(fn w x y . args)` , where `x` and `y` are the offset within the window `w` at which the icon is to be drawn, and `args` is a list of arbitrary arguments, e.g., the size of the icon, that are passed through to the drawing function. The icon is drawn in `xor` mode, so it must be drawn using only “plain” drawing functions, without resetting window attributes. The returned value is `(x y)` at the cursor position when a button is clicked. `dx` and `dy`, if specified, are offsets of `x` and `y` from the cursor position.

The following function gets a position by moving a “ghost” box icon.

`(window-get-box-position w width height &optional (dx 0) (dy 0))`
By default, the lower-left corner of the box is placed at the cursor position; `dx` and `dy` may be used to offset the box from the cursor, e.g., to move the box by a different corner. The returned value is `(x y)` at the cursor position when a button is clicked.

The following function gets coordinates of a box of arbitrary size and position.

`(window-get-region w)`
The user first clicks for one corner of the box, moves the mouse and clicks again for the opposite corner, then moves the box into the desired position. The returned value is `((x y) (width height))`, where `(x y)` is the lower-left corner of the box.

The following function gets the size of a box by mouse selection, echoing the size in pixels below the box. `offsety` should be at least `30` to leave room to display the size of the box.

`(window-get-box-size w offsetx offsety)`
The following function adjusts one side of a box.

`(window-adjust-box-side w x y width height side)`
`side` specifies the side of the box to be adjusted: `left`, `right`, `top`, or `bottom`. The result is `((x y) (width height))` for the resulting box.

`(window-get-circle w &optional center:vector)`
`(window-get-ellipse w &optional center:vector)`
These functions interactively get a circle or ellipse. For an ellipse, a circle is gotten first for the horizontal size; then the vertical size of the ellipse is adjusted. `window-get-circle` returns `((x y) radius)`. `window-get-ellipse` returns `((x y) (xradius yradius))`.

`window-track-mouse` is the basic function for following the mouse and performing some action as it moves. This function is used in the implementation of menus and the mouse-interaction functions described in this section.

`(window-track-mouse w fn &optional outflg)`

Each time the mouse position changes or a mouse button is pressed, the function `fn` is called with arguments `(x y code)` where `x` and `y` are the cursor position, `code` is a button code (`0` if no button, `1` for the left button, `2` for the middle button, or `3` for the right button). `window-track-mouse` continues to track the mouse until `fn` returns a value other than `nil`, at which time `window-track-mouse` returns that value. Usually, it is a good idea for `fn` to return a value other than `nil` upon a mouse click. If the argument `outflg` is non-`nil`, the function `fn` will be called for button clicks outside the window `w`; note, however, that such clicks will not be seen if the containing window intercepts them, so that this feature will work only if the window `w` is inside another Lisp user window.