Skip to content

get_mpositionGetMpositionGetMpositionget_mpositionT_get_mposition🔗

Short description🔗

get_mpositionGetMpositionGetMpositionget_mpositionT_get_mposition — Query the mouse position.

Signature🔗

get_mposition( window WindowHandle, out point.y Row, out point.x Column, out integer Button )void GetMposition( const HTuple& WindowHandle, HTuple* Row, HTuple* Column, HTuple* Button )static void HOperatorSet.GetMposition( HTuple windowHandle, out HTuple row, out HTuple column, out HTuple button )def get_mposition( window_handle: HHandle ) -> Tuple[int, int, int]

Herror T_get_mposition( const Htuple WindowHandle, Htuple* Row, Htuple* Column, Htuple* Button )

void HWindow::GetMposition( Hlong* Row, Hlong* Column, Hlong* Button ) const

void HWindow.GetMposition( out int row, out int column, out int button )

Description🔗

get_mpositionGetMposition returns the pixel accurate image coordinates of the mouse pointer in the output window and the mouse button pressed. These values are returned regardless of the state of the mouse buttons (pressed or not pressed). If at least one mouse button is pressed, the state of the modifier keys is returned as well. If no mouse button is pressed, get_mpositionGetMposition returns 0 in Buttonbuttonbutton, even if a modifier key is pressed. The following values are assigned to the individual buttons and keys:

  • 0: No button,

  • 1: Left button,

  • 2: Middle button,

  • 4: Right button,

  • 8: Shift key,

  • 16: Ctrl key,

  • 32: Alt key.

The sum of the values for all pressed buttons/keys is returned in Buttonbuttonbutton.

The origin of the coordinate system is located in the left upper corner of the window. For graphics windows the coordinates Rowrowrow and Columncolumncolumn are expressed with consideration of the current image part (see set_partSetPart).

If subpixel accurate image coordinates are required, you can use the operator get_mposition_sub_pixGetMpositionSubPix.

Attention🔗

get_mpositionGetMposition fails (returns 5 (H_MSG_FAIL)) if the mouse pointer is not located within the window. In this case, no values are returned.

Execution information🔗

Execution information
  • Multithreading type: reentrant (runs in parallel with non-exclusive operators).

  • Multithreading scope: global (may be called from any thread).

  • Processed without parallelization.

Parameters🔗

WindowHandlewindowHandlewindow_handle (input_control) window → (handle)HTuple (HHandle)HWindow, HTuple (IntPtr)HHandleHtuple (handle)

Window handle.

Rowrowrow (output_control) point.y → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Row coordinate of the mouse cursor in the image coordinate system.

Columncolumncolumn (output_control) point.x → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Column coordinate of the mouse cursor in the image coordinate system.

Buttonbuttonbutton (output_control) integer → (integer)HTuple (Hlong)HTuple (int / long)intHtuple (Hlong)

Mouse button(s) pressed or 0.

Result🔗

get_mpositionGetMposition returns the value 2 (H_MSG_TRUE). If the mouse pointer is not located within the window, 5 (H_MSG_FAIL) is returned.

Combinations with other operators🔗

Combinations

Possible predecessors

open_windowOpenWindow

Alternatives

get_mbuttonGetMbutton, get_mposition_sub_pixGetMpositionSubPix, get_mbutton_sub_pixGetMbuttonSubPix

See also

open_windowOpenWindow

Module🔗

Foundation