Documentation for Win32lib v0.60.6
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 clickPointerLeft()   Simulates the clicking of the left mouse button.
  • proc 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.60.6
    Table of Contents

    [proc]
    captureMouse
    ( window )

    Send all mouse events to window.

    Category: Mouse

    To release the mouse, use releaseMouse.

    Example:

              -- grab the mouse for TheWindow
               captureMouse( TheWindow )
    

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


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    clickPointerLeft
    ()

    Simulates the clicking of the left mouse button.

    Category: Mouse

    Example

      clickPointerLeft()
    

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


    Documentation for Win32lib v0.60.6
    Table of Contents

    [proc]
    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, clickPointerLeft, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, restoreMousePointer, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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 poping 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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, setDragPointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setMousePointer, setPointerPos


    Documentation for Win32lib v0.60.6
    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 system pointer, or one created with the createMousePointer function, or a path to .CUR or .ANI file.

    System mouse pointers are:

  • ArrowPointer: Standard arrow
  • IBeamPointer: Text I-Beam
  • WaitPointer: Hourglass
  • CrossPointer: Crosshair
  • UpArrowPointer: Vertical arrow
  • SizeNWSEPointer: Double-pointed arrow pointing northwest and southeast
  • SizeNESWPointer: Double-pointed arrow pointing northeast and southwest
  • SizeWEPointer: Double-pointed arrow pointing west and east
  • SizeNSPointer: Double-pointed arrow pointing north and south
  • SizeAllPointer: Same as SizePointer
  • NoPointer: Slashed circle
  • AppStartingPointer: Standard arrow with small hourglass
  • IconPointer: Four-pointed arrow
  • Null: This is identical to calling restoreMousePointer()
  • -1: This pops all pushed mouse shapes and restores the default one for id.

    These system pointers can also be specified as a string value: li "ARROW", li "IBEAM", li "WAIT" or "HOURGLASS", li "CROSS", li "UPARROW", li "SIZENWSE", li "SIZENESW", li "SIZEWE", li "SIZENS", li "SIZEALL", li "NO" or "NOT", li "APPSTARTING", li "ICON", li "NULL", li "DEFAULT" 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} )
    

    setMousePointer( ListPanel, "SpecialCursor.cur") setMousePointer( {WindowX}, "hourglass")

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


    Documentation for Win32lib v0.60.6
    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, clickPointerLeft, createMousePointer, dragPointerTo, getPointerPos, getPointerRelPos, getWheelScrollLines, loadCursor, releaseMouse, restoreMousePointer, setDragPointer, setMousePointer