Mouse

Moving

This condition is satisfied when you move the mouse.

Automatically generated code (generated by the behavior dialog):

# Apply impulse to circle1 when mouse is moving.
circle1.bind(MOVING, system.evtHandler, APPLYIMPULSE,
            **{'ix': 5, 'iy': 5, 'bx': 0, 'by': 0})

Manually created code (equivalent to the automatically generated code shown above):

def applyImpulse(event, source, ix, iy, bx, by):
    source.applyImpulse(ix, iy, bx, by)

circle1.bind(MOVING, applyImpulse, ix=5, iy=5, bx=0, by=0})

Dragging

This condition is satisfied when the mouse is moving while any of the buttons is down.

# Apply force to circle1 when mouse is being dragged.
circle1.bind(DRAGGING, system.evtHandler, APPLYFORCE,
            **{'fx': 5, 'fy': 5, 'bx': 0, 'by': 0})

Manually created code (equivalent to the automatically generated code shown above):

def applyForce(event, source, fx, fy, bx, by):
    source.applyForce(ix, iy, bx, by)

circle1.bind(DRAGGING, applyForce, fx=5, fy=5, bx=0, by=0})

Enter

This condition is satisfied when the mouse enters into the bound element.

# Set spring1's visibility when mouse enters into rectangle3.
rectangle3.bind(ENTER, system.evtHandler, SETVISIBILITY,
                **{'target': spring1, 'visible': False})

Manually created code (equivalent to the automatically generated code shown above):

def onEnterRectangle3(event, source):
    spring1.visible = False

rectangle3.bind(ENTER, onEnterRectangle3)

Note

This condition is checked only when the mouse is moving. If a rigid body moves and causes the cursor to be in its boundaries while the mouse is motionless, this doesn’t trigger an ENTER event.

Leave

This condition is satisfied when the mouse leaves the bound element.

# Set spring1's visibility when mouse leaves rectangle3.
rectangle3.bind(ENTER, system.evtHandler, SETVISIBILITY,
                **{'target': spring1, 'visible': True})

Manually created code (equivalent to the automatically generated code shown above):

def onLeaveRectangle3(event, source):
    spring1.visible = True

rectangle3.bind(LEAVE, onLeaveRectangle3)

Note

This condition is checked only when the mouse is moving. If a rigid body moves and causes the cursor to be outside its boundaries while the mouse is motionless, this doesn’t trigger a LEAVE event.

Hover

This condition is satisfied while the mouse is hovering on the bound element.

# Adjust circle1's velocity while mouse is hovering on.
circle1.bind(HOVER, system.evtHandler, ADJUSTVELOCITY, **{'d_vr': .2})

Manually created code (equivalent to the automatically generated code shown above):

def onHoverCircle(event, source, dvr):
    source.vr += dvr

circle1.bind(HOVER, onHoverCircle, dvr=.2)

Note

This condition is checked only when the mouse is moving.

Left button

Down

This condition is satisfied when the left mouse button is pressed down.

Automatically generated code (generated by the behavior dialog):

# Adjust circle1's angle when left mouse button is pressed down.
circle1.bind(LEFTDOWN, system.evtHandler, ADJUSTANGLE, **{'d_angle': .52})

Manually created code (equivalent to the automatically generated code shown above):

def changeAngle(event, source):
    circle1.angle += .52

circle1.bind(LEFTDOWN, changeAngle)

Up

This condition is satisfied when the left mouse button is released.

Automatically generated code (generated by the behavior dialog):

# Create a circle when left mouse button is released.
rectangle1.bind(LEFTUP, system.evtHandler, CREATECIRCLE,
                **{'x': 20, 'y': 30, 'radius': 3})

Manually created code (equivalent to the automatically generated code shown above):

def createCircle(event, source, x, y, radius):
    circle(x, y, r)

circle1.bind(LEFTUP, createCircle, 20, 30, 3})

Double-click

This condition is satisfied when the left mouse button is pressed down twice in quick succession.

Automatically generated code:

# Destroy circle2 when left mouse button is double clicked.
circle4.bind(LEFTDCLICK, system.evtHandler, DESTROY,
         **{'target': circle2, 'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def destroy(event, source, target):
    system.destroy(target)

circle4.bind(LEFTDCLICK, destroy, target=circle2)

Down on element

This condition is satisfied when the user presses the left mouse button on the object the event is bound to.

Automatically generated code:

# Set polygon2's visibility when left mouse button is pressed down on polygon2.
polygon2.bind(LEFTDOWNON, system.evtHandler, SETVISIBILITY,
            **{'visible': False})

Manually created code (equivalent to the automatically generated code shown above):

def hide(event, source):
    source.visible = False

polygon2.bind(LEFTDOWNON, hide)

Up on element

This condition is satisfied when the user releases the left mouse button on the object the event is bound to.

Automatically generated code:

# Constrain circle2's rotational motion when left mouse button is released on circle2.
polygon3.bind(LEFTUPON, system.evtHandler, CONSTRAINROTATION,
              **{'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def constrainRotation(event, source, target):
    target.fixedRotation = True

polygon3.bind(LEFTUPON, constrainRotation, target=circle2)

Note

If you press the left mouse button down on an empty area and drag it onto the bound element and release the mouse this will still trigger the prescribed action.

Double-click on element

This condition is satisfied when the user double clicks on the bound element.

Automatically generated code:

# Set gravity when left mouse button is double clicked on rectangle2.
rectangle2.bind(LEFTDCLICKON, system.evtHandler, SETGRAVITY,
                **{'gx': 0, 'gy': -10})

Manually created code (equivalent to the automatically generated code shown above):

def setGravity(event, source, gx, gy):
    system.gravity = [gx, gy]

rectangle2.bind(LEFTDCLICK, setGravity, gx=0, gy=-10)

Note

If the system.zeroGravity is True then in addition to setting the gravity vector, system.zeroGravity would have to be set to False as well.

Right button

Down

This condition is satisfied when the right mouse button is pressed down.

Automatically generated code (generated by the behavior dialog):

# Adjust circle1's angle when right mouse button is pressed down.
circle1.bind(RIGHTDOWN, system.evtHandler, ADJUSTANGLE, **{'d_angle': .52})

Manually created code (equivalent to the automatically generated code shown above):

def changeAngle(event, source):
    circle1.angle += .52

circle1.bind(RIGHTDOWN, changeAngle)

Up

This condition is satisfied when the right mouse button is released.

Automatically generated code (generated by the behavior dialog):

# Create a circle when right mouse button is released.
rectangle1.bind(RIGHTUP, system.evtHandler, CREATECIRCLE,
                **{'x': 20, 'y': 30, 'radius': 3})

Manually created code (equivalent to the automatically generated code shown above):

def createCircle(event, source, x, y, radius):
    circle(x, y, r)

circle1.bind(RIGHTUP, createCircle, 20, 30, 3})

Double-click

This condition is satisfied when the right mouse button is pressed down twice in quick succession.

Automatically generated code:

# Destroy circle2 when right mouse button is double clicked.
circle4.bind(RIGHTDCLICK, system.evtHandler, DESTROY,
         **{'target': circle2, 'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def destroy(event, source, target):
    system.destroy(target)

circle4.bind(RIGHTDCLICK, destroy, target=circle2)

Down on element

This condition is satisfied when the user presses the right mouse button on the object the event is bound to.

Automatically generated code:

# Set polygon2's visibility when right mouse button is pressed down on polygon2.
polygon2.bind(RIGHTDOWNON, system.evtHandler, SETVISIBILITY,
            **{'visible': False})

Manually created code (equivalent to the automatically generated code shown above):

def hide(event, source):
    source.visible = False

polygon2.bind(RIGHTDOWNON, hide)

Up on element

This condition is satisfied when the user releases the right mouse button on the object the event is bound to.

Automatically generated code:

# Constrain circle2's rotational motion when right mouse button is released on circle2.
polygon3.bind(RIGHTUPON, system.evtHandler, CONSTRAINROTATION,
              **{'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def constrainRotation(event, source, target):
    target.fixedRotation = True

polygon3.bind(RIGHTUPON, constrainRotation, target=circle2)

Note

If you press the right mouse button down on an empty area and drag it onto the bound element and release the mouse this will still trigger the prescribed action.

Double-click on element

This condition is satisfied when the user double clicks on the bound element.

Automatically generated code:

# Set gravity when right mouse button is double clicked on rectangle2.
rectangle2.bind(RIGHTDCLICKON, system.evtHandler, SETGRAVITY,
                **{'gx': 0, 'gy': -10})

Manually created code (equivalent to the automatically generated code shown above):

def setGravity(event, source, gx, gy):
    system.gravity = [gx, gy]

rectangle2.bind(RIGHTDCLICK, setGravity, gx=0, gy=-10)

Note

If the system.zeroGravity is True then in addition to setting the gravity vector, system.zeroGravity would have to be set to False as well.

Middle button

Down

This condition is satisfied when the middle mouse button is pressed down.

Automatically generated code (generated by the behavior dialog):

# Adjust circle1's angle when middle mouse button is pressed down.
circle1.bind(MIDDOWN, system.evtHandler, ADJUSTANGLE, **{'d_angle': .52})

Manually created code (equivalent to the automatically generated code shown above):

def changeAngle(event, source):
    circle1.angle += .52

circle1.bind(MIDDOWN, changeAngle)

Up

This condition is satisfied when the middle mouse button is released.

Automatically generated code (generated by the behavior dialog):

# Create a circle when middle mouse button is released.
rectangle1.bind(MIDUP, system.evtHandler, CREATECIRCLE,
                **{'x': 20, 'y': 30, 'radius': 3})

Manually created code (equivalent to the automatically generated code shown above):

def createCircle(event, source, x, y, radius):
    circle(x, y, r)

circle1.bind(MIDUP, createCircle, 20, 30, 3})

Double-click

This condition is satisfied when the middle mouse button is pressed down twice in quick succession.

Automatically generated code (generated by the behavior dialog):

# Destroy circle2 when middle mouse button is double clicked.
circle4.bind(MIDDCLICK, system.evtHandler, DESTROY,
         **{'target': circle2, 'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def destroy(event, source, target):
    system.destroy(target)

circle4.bind(MIDDCLICK, destroy, target=circle2)

Down on element

This condition is satisfied when the user presses the middle mouse button on the object the event is bound to.

Automatically generated code (generated by the behavior dialog):

# Set polygon2's visibility when middle mouse button is pressed down on polygon2.
polygon2.bind(MIDDOWNON, system.evtHandler, SETVISIBILITY,
            **{'visible': False})

Manually created code (equivalent to the automatically generated code shown above):

def hide(event, source):
    source.visible = False

polygon2.bind(MIDDOWNON, hide)

Up on element

This condition is satisfied when the user releases the middle mouse button on the object the event is bound to.

Automatically generated code (generated by the behavior dialog):

# Constrain circle2's rotational motion when middle mouse button is released on circle2.
polygon3.bind(MIDUPON, system.evtHandler, CONSTRAINROTATION,
              **{'target': circle2})

Manually created code (equivalent to the automatically generated code shown above):

def constrainRotation(event, source, target):
    target.fixedRotation = True

polygon3.bind(MIDUPON, constrainRotation, target=circle2)

Note

If you press the middle mouse button down on an empty area and drag it onto the bound element and release the mouse this will still trigger the prescribed action.

Double-click on element

This condition is satisfied when the user double clicks on the bound element.

Automatically generated code (generated by the behavior dialog):

# Set gravity when middle mouse button is double clicked on rectangle2.
rectangle2.bind(MIDDCLICKON, system.evtHandler, SETGRAVITY,
                **{'gx': 0, 'gy': -10})

Manually created code (equivalent to the automatically generated code shown above):

def setGravity(event, source, gx, gy):
    system.gravity = [gx, gy]

rectangle2.bind(MIDDCLICK, setGravity, gx=0, gy=-10)

Note

If the system.zeroGravity is True then in addition to setting the gravity vector, system.zeroGravity would have to be set to False as well.