Documentation for Win32lib v0.70.18
Table of Contents

Mouse

These are routines that deal with the mouse and mouse pointer.


  • proc captureMouse( window )    Send all mouse events to window.
  • proc changeMousePointer( object id, object pointer )    Set the pointer the mouse displays when in id, without saving the previous shape.
  • proc clickPointerLeft()   Simulates the clicking of the left mouse button.
  • func createMousePointer( hotspotX, hotspotY, image )   Create a new mouse pointer.
  • proc dragPointerTo(sequence pos)   Simulates the draging of the left mouse button to a specified position.
  • func getPointerPos()   Find where the mouse pointer is on the screen.
  • func getPointerRelPos(integer id)   Retrieves relative position of the mouse.
  • func getWheelScrollLines()   Retrieves the number of lines that a mouse wheel movement represents.
  • func loadCursor(sequence CursorFile)   Loads a cursor from a file.
  • proc releaseMouse()   Return control of the mouse to Windows.
  • proc restoreMousePointer( object id)    Gets back the previous pointer the mouse had before the last setMousePointer call.
  • proc setDragPointer( object style)   Sets the mouse pointer shape to use when dragging.
  • proc setMousePointer( object id, object pointer )    Set the pointer the mouse displays when in id.
  • proc setPointerPos(sequence pos)   Moves the mouse pointer to a specified spot on the screen.

    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    captureMouse
    ( window )

    Send all mouse events to window.

    Category: Mouse

    All mouse coordinates become relative to window. To release the mouse, use releaseMouse.

    Example:

              -- grab the mouse for TheWindow
               captureMouse( TheWindow )
    

    See Also: changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    changeMousePointer
    ( object id, object pointer )

    Set the pointer the mouse displays when in id, without saving the previous shape.

    Category: Mouse

    This behaves like setMousePointer(), but does not stack the previous shape for later restore. It just changes the top of the stack shape.
    However, using a special style value (0, -1 or -2) will cause no change to take place.

    Use this routine, rather than setMousePointer(), when you continuously monitor the mouse position and update cursor accordingly, as it avoids a lag effect when the mouse lingers in some area of a window and then leaves to an area that displays another shape.

    Example:

         -- Change mouse pointer in MyWindow and all its child controls to hourglass
          setMousePointer( {MyWindow}, WaitPointer )
         -- Do some long job, and allow pinpointing some place
         --    changeMousePointer(MyWindow,Cross)
         -- Restore the shape that was changed for WaitPointer.
          restoreMousePointer( {MyWindow} )
    

    changeMousePointer( ListPanel, "SpecialCursor.cur") -- this one does all children of WindowX recursively changeMousePointer( {WindowX}, "hourglass")

    See Also: captureMouse, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    clickPointerLeft
    ()

    Simulates the clicking of the left mouse button.

    Category: Mouse

    See Also: captureMouse, changeMousePointer, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    createMousePointer
    ( hotspotX, hotspotY, image )

    Create a new mouse pointer.

    Category: Mouse

    The hotspotX and hotspotY values are the "hotspot". The image is a 2x2 text sequence of the pointer. Bytes are interpreted as follows:

       ' ' = transparent
       '.' = solid white
       'x' = solid black

    Example:

           constant PlusPointer = createMousePointer( 8, 8, {
              "     xxxxxx      ",
              "     x....xx     ",
              "     x....xx     ",
              "     x....xx     ",
              "     x....xx     ",
              "xxxxxx....xxxxxx ",
              "x..............xx",
              "x..............xx",
              "x..............xx",
              "x..............xx",
              "xxxxxx....xxxxxxx",
              " xxxxx....xxxxxxx",
              "     x....xx     ",
              "     x....xx     ",
              "     x....xx     ",
              "     xxxxxxx     ",
              "      xxxxxx     "} )
    

    -- set as pointer for MyWindow setMousePointer( MyWindow, PlusPointer )

    See Also: captureMouse, changeMousePointer, clickPointerLeft, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    dragPointerTo
    (sequence pos)

    Simulates the draging of the left mouse button to a specified position.

    Category: Mouse

    pos is a two-element sequence that contains the X and Y location to drag the pointer to.

    Example

      dragPointerTo( {100, 200} )
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getPointerPos
    ()

    Find where the mouse pointer is on the screen.

    Returns: SEQUENCE: {X,Y} The mouse position.

    Category: Mouse

    This returns a two-element sequence that specifies the X and Y position of the mouse pointer.

    Example:

     sequence pos
    

    pos = getPointerPos() if pos[1] > 200 then -- code goes here... end if

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getPointerRelPos
    (integer id)

    Retrieves relative position of the mouse.

    Returns: SEQUENCE: Mouse {x,y} position, relative to the control specified by id.

    Category: Mouse

    Example:

     sequence pos
    

    pos = getPointerRelPos(myWindow) if pos[1] > 200 then -- code goes here... end if

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    getWheelScrollLines
    ()

    Retrieves the number of lines that a mouse wheel movement represents.

    Returns: ATOM: The number of lines.

    Category: Mouse

    Example:

      atom cnt
      cnt = getWheelScrollLines()
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [func]
    loadCursor
    (sequence CursorFile)

    Loads a cursor from a file.

    Returns: ATOM: The handle to a loaded cursor

    Category: Mouse

    If this returns zero, then the cursor was not loaded.

    Example:

          mC = loadCursor("hands.ani")
          setMousePointer(myList, mC)
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    releaseMouse
    ()

    Return control of the mouse to Windows.

    Category: Mouse

    This is called after captureMouse to put control of the mouse back to normal.

    Example:

              -- release the mouse.
               releaseMouse()
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    restoreMousePointer
    ( object id)

    Gets back the previous pointer the mouse had before the last setMousePointer call.

    Category: Mouse

    This restores the pointer shape for id by popping it from the id's stack.
    id can either be a single control ID, or a sequence containing a control ID. You use the second form to restore the pointer for all the controls contained in id.

    Example:

    -- Change mouse pointer in MyWindow to hourglass
     setMousePointer( {MyWindow}, WaitPointer )
    -- Do some long job...
    . . .
    -- Restore the previous shape.
     restoreMousePointer( {MyWindow} )
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    setDragPointer
    ( object style)

    Sets the mouse pointer shape to use when dragging.

    Category: Mouse

    Win32lib supports four cursor shapes for dragging.
    style can be either an atom (handle) or a sequence of four handles. If it is an atom then set all four drag pointers to the same value.
    The sequence represents these shapes:

    If style is a sequence, if any element is 0 then the current value for this position is not changed.

    Initially all shapes are set to the CrossPointer.

    Handles can be either one of the predefined system shapes, one created by createMousePointer() or one returned by loadCursor().

    Example:

          setDragPointer( IconPointer )
    

    setDragPointer( {IconPointer, -- set the 'normal' shape 0 -- leave exsting 'Shift' shape alone loadCursor(mycursor), -- load 'Ctrl' shape from a file. } )

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    setMousePointer
    ( object id, object pointer )

    Set the pointer the mouse displays when in id.

    Category: Mouse

    This saves the current pointer for id by pushing it onto the id's stack and sets the pointer as the new shape. You can get the previous pointer shape by calling restoreMousePointer().

    id can either be a single control ID, or a sequence that contains a control ID. You use the second form to set the pointer for all the controls contained in id.

    The initial mouse pointer displayed is the ArrowPointer, except for TextEdit and MleText controls, which use the IBeamPointer.

    The pointer can either be a special value, a system pointer, or one created with the createMousePointer function, or a path to .CUR or .ANI file. Special values are:

  • 0: restore mouse pointer to its previous shape;
  • -1: restor mouse pointer to its default shape, popping off any change;
  • -2: do nothing

    Repeated use of setMousePointer() with the same shape will result in it being stored only once. This way, a single call to restoreMousePointer() willl restore the previous shape, if any.

    If the mouse pointer is not above id, the cursor shape change is effective only when the cursor comes above id.

    Known system mouse pointers are listed here Example:

         -- Change mouse pointer in MyWindow and all its child controls to hourglass
          setMousePointer( {MyWindow}, WaitPointer )
         -- Do some long job...
         . . .
         -- Restore the previous shape.
          restoreMousePointer( {MyWindow} )
    

    -- use a shape stored in some external file setMousePointer( ListPanel, "SpecialCursor.cur") -- this one does all children of WindowX recursively setMousePointer( {WindowX}, "hourglass")

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setPointerPos


    Documentation for Win32lib v0.70.18
    Table of Contents

    [proc]
    setPointerPos
    (sequence pos)

    Moves the mouse pointer to a specified spot on the screen.

    Category: Mouse

    pos is a two-element sequence that specifies the X and Y position that the mouse pointer is to be moved to.

    Example:

          -- Move the mouse pointer to 120,76
          setPointerPos({120, 76})
    

    See Also: captureMouse, changeMousePointer, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer