< index < 5. Image toolkit | ===================================== 6. Mouse support ===================================== | > 7. File parser

By default, the mouse cursor in visible in windowed mode, hidden in fullscreen mode. You can change it with :

    C++ : static void TCODMouse::showCursor(bool visible)
    C   : void TCOD_mouse_show_cursor(bool visible)
    Py  : mouse_show_cursor(visible)

Parameter | Description
--- | ---
visible | If true, this function turns the mouse cursor on. Else it turns the mouse cursor off.

You can get the current cursor status (hidden or visible) with :

    C++ : static bool TCODMouse::isCursorVisible()
    C   : bool TCOD_mouse_is_cursor_visible()
    Py  : mouse_is_cursor_visible()

You can set the cursor position (in pixel coordinates, 0x0 = the window top left corner) with :

    C++ : static void TCODMouse::move(int x, int y)
    C   : void TCOD_mouse_move(int x, int y)
    Py  : mouse_move(x, y)

Parameter | Description
--- | ---
x,y | New coordinates of the mouse cursor in pixels.

You can read the current mouse status with :

    typedef struct {
      int x,y;
      int dx,dy;
      int cx,cy;
      int dcx,dcy;
      unsigned lbutton : 1;
      unsigned rbutton : 1;
      unsigned mbutton : 1;
      unsigned lbutton_pressed : 1;
      unsigned rbutton_pressed : 1;
      unsigned mbutton_pressed : 1;
    } TCOD_mouse_t;

    C++ : static TCOD_mouse_t TCODMouse::getStatus()
    C   : TCOD_mouse_t TCOD_mouse_get_status()
    Py  : mouse_get_status()

Field name | Description
--- | ---
x,y | Absolute position of the mouse cursor in pixels relative to the window top-left corner.
dx,dy | Movement of the mouse cursor since the last call in pixels.
cx,cy | Coordinates of the console cell under the mouse cursor (pixel coordinates divided by the font size).
dcx,dcy | Movement of the mouse since the last call in console cells (pixel coordinates divided by the font size).
lbutton | true if the left button is pressed.
rbutton | true if the right button is pressed.
mbutton | true if the middle button (or the wheel) is pressed.
lbutton_pressed | true if the left button was pressed and released.
rbutton_pressed | true if the right button was pressed and released.
mbutton_pressed | true if the middle button was pressed and released.