GViewListener API
Although the control is created from the GView class the only method you are likely to use is the addListener, all the functionality you need is in the GViewListener class. You would not access the functionality directly rather you would create a user-defined listener class that extends the GViewListener class and access the functionality through that class.
This guide details the most common functionality you are likely to use.
Event Handlers
Whenever Processing fires a mouse event it will be passed to the GView class to see if it needs to process it. Provided the control is visible, enabled and the mouse is over the control it forwards the event to the GViewListener class.
IMPORTANT: The event handlers are only called when the mouse is over the control
Event handlers | Description |
---|---|
|
Event handlers for when the mouse enters or leaves the view. The equivalent methods used in the main sketch code are executed when the mouse enters or leaves the application (sketch). |
|
These behave in the same way as the equivalent Processing methods so look at the Processing documents for more information. |
|
This method would be used instead of the onMouse??? methods shown above. It allows the user
to process the event in a single method. |
Key modifiers
A mouse event also includes information about which modifier keys were pressed when the event was generated. These methods allow you to find out which keys were down.
Key modifier methods | Description |
---|---|
|
These behave in the same way as the equivalent Processing methods so look at the Processing documents for more information. |
|
This method return an integer whose state indicates which if any of the above keys are down. |
Mouse information
Method | Description |
---|---|
|
Equivalent to mouseX , mouseY , pmouseX and pmouseY but
the mouse positions are relative to the top-left corner of the view. |
|
Which button if any is pressed |
|
How much the mouse wheel was rotated |
|
Returns true if the mouse is over the control |
|
Returns true if a mouse button is pressed |
View information
|
Similar to Processing's width and height but they return the width
and height of the view. |
|
Returns true if using the P3D renderer else returns false. |
|
Returns the graphics object associated with this view. |
|
Returns the PApplet object used to create this view. |
Event information
These methods are included for the sake of completeness and will rarely if ever be needed.
|
Returns the last event processed by the listener. Useful if you need the event to do something not covered in this API. |
|
Always returns Event.MOUSE |
|
Returns the platform native event object of the last event processed by the listener. |