Menu

Mouse

Gwenn

Mouse

Classes and Methods

cogpy.Mouse()

      Handler class for dealing with Mouse I/O.

      dragdrop( id, button="left", shift=False, alt=False, cmd=False, windows=False, ctrl=False )

            Trigger-style function--waits until the specified button is pressed, then drags the object specified by id with the mouse movement until the mouse button is released, then returns.

            When it returns, will set the cogpy.Experiment output attribute to the return value of mouse.get_pos().

            Note: Mouse.dragdrop should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.

            If one or more of the modifier parameters (shift, alt, ctrl, windows, cmd) are set to True, then the
            corresponding keys must be down when the specified button is pressed for the dragging to initialize.

      get_button( button )

            Returns True if the specified button is currently pressed, False otherwise.

      get_pos()

            Returns an (x,y) tuple corresponding to the position of the mouse cursor on the screen.

            Uses the cogpy.Display coordinate system, not the screen coordinate system.

      left( id=None, double=False, shift=False, alt=False, cmd=False, windows=False, ctrl=False )

            Trigger-style function--waits until the left mouse button is pressed, then returns. If the id parameter is specified
            and corresponds to a valid cogpy.Display object, will wait until the left mouse button is clicked over that object.

            When it returns, will set the cogpy.Experiment output attribute to the return value of mouse.get_pos().

            Note: Mouse.left should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.

            If one or more of the modifier parameters (shift, alt, ctrl, windows, cmd) are set to True, then the
            corresponding keys must be down when the left mouse button is pressed for the function to return.

            If double is set to True, then left mouse button must be double-clicked for the function to return.

      middle( id=None, shift=False, alt=False, cmd=False, windows=False, ctrl=False )

            Trigger-style function--waits until the middle mouse button is pressed, then returns. If the id parameter is specified
            and corresponds to a valid cogpy.Display object, will wait until the middle mouse button is clicked over that object.

            When it returns, will set the cogpy.Experiment output attribute to the return value of mouse.get_pos().

            Note: Mouse.middle should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.

            If one or more of the modifier parameters (shift, alt, ctrl, windows, cmd) are set to True, then the
            corresponding keys must be down when the middle mouse button is pressed for the function to return.

      over( id )

            Trigger-style function--waits until the mouse cursor is moved over the display object with the specified id,
            then returns.

            When it returns, will set the cogpy.Experiment output attribute to the return value of mouse.get_pos().

            Note: Mouse.over should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.

      right( id=None, double=False, shift=False, alt=False, cmd=False, windows=False, ctrl=False )

            Trigger-style function--waits until the right mouse button is pressed, then returns. If the id parameter is specified
            and corresponds to a valid cogpy.Display object, will wait until the right mouse button is clicked over that object.

            When it returns, will set the cogpy.Experiment output attribute to the return value of mouse.get_pos().

            Note: Mouse.right should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.

            If one or more of the modifier parameters (shift, alt, ctrl, windows, cmd) are set to True, then the
            corresponding keys must be down when the right mouse button is pressed for the function to return.

            If double is set to True, then right mouse button must be double-clicked for the function to return.

      scroll( id=None, dir=None )

            Trigger-style function--waits until the mouse scrolls in the specified direction, then returns. If no direction is
            specified, will return when the scrollwheel moves in either direction.

            When it returns, will set the cogpy.Experiment output attribute to a 3-tuple representing the (x,y) position of
            the mouse cursor and the direction of scrolling.

            Note: Mouse.scroll should only be called in a yield statement within a cogpy.Experiment instance. Will
            return a generator function otherwise.


Example Usage

import cogpy

class Test(cogpy.Experiment):
    display = cogpy.Display()
    mouse = cogpy.Mouse()

    def start(self):
        yield mouse.left()
        display.add("circle",9,0,0,radius=50) #id=9
        yield mouse.right(9,ctrl=True)
        print self.output
        print mouse.get_pos()
        yield mouse.dragdrop(9)

exp = Test()
exp.run()

Interpreter output:

(-23,45)
(-23,45)

Related

Wiki: Home

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.