An XYPad is similar to a trackpad. It is controlled by clicking and dragging a selector (tracker bubble) across the pad.
An XYPad is created by the following function. It is specified by two diagonal corners, the function to call when the user interacts with it, its various colors (background, foreground, and outline), and the various thicknesses (outline, tracker, and crosshairs).
Function | Description |
XYPad(x1, y1, x2, y2, updateFunction, foreground, background, outline, outlineThickness, trackerRadius, crosshairsThickness) | Creates an XYPad object.
|
You can create an XYPad as follows:
# function to specify what happens when tracker bubble is moved def printPosition(x, y): print x, y # replace this by whatever you want to do using x and y trackpad = XYPad(100, 50, 200, 150, printPosition, Color.BLACK, Color.WHITE, Color.BLACK, 0) display1.add(trackpad)
Once an XYPad has been created, the following functions are available:
Function | Description |
trackpad.getPosition() | Returns the current x and y coordinates of the XYPad, relative to the XYPad (top left corner is 0,0). |
trackpad.setPosition(newX, newY) | Sets the current position of the XYPad’s selector. |