mirror of
https://github.com/sojamo/controlp5
synced 2024-11-22 14:07:55 +01:00
Add 'isTouch' to force touchscreen mode
This commit is contained in:
parent
665b0c1aa5
commit
2869c82aa7
@ -148,6 +148,8 @@ public class ControlP5 extends ControlP5Base {
|
|||||||
protected boolean isAnnotation;
|
protected boolean isAnnotation;
|
||||||
boolean isAndroid = false;
|
boolean isAndroid = false;
|
||||||
|
|
||||||
|
public boolean isTouch = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance of controlP5.
|
* Create a new instance of controlP5.
|
||||||
*
|
*
|
||||||
|
@ -451,18 +451,32 @@ public final class ControlWindow {
|
|||||||
*/
|
*/
|
||||||
public void mouseEvent( MouseEvent theMouseEvent ) {
|
public void mouseEvent( MouseEvent theMouseEvent ) {
|
||||||
if ( isMouse ) {
|
if ( isMouse ) {
|
||||||
|
final int action = theMouseEvent.getAction();
|
||||||
|
|
||||||
|
if ( cp5.isTouch ) {
|
||||||
|
// Ignore certain events when touch-enabled
|
||||||
|
if ( action == MouseEvent.CLICK || action == MouseEvent.MOVE ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mouseX = theMouseEvent.getX( ) - cp5.pgx - cp5.ox;
|
mouseX = theMouseEvent.getX( ) - cp5.pgx - cp5.ox;
|
||||||
mouseY = theMouseEvent.getY( ) - cp5.pgy - cp5.oy;
|
mouseY = theMouseEvent.getY( ) - cp5.pgy - cp5.oy;
|
||||||
if ( theMouseEvent.getAction( ) == MouseEvent.PRESS ) {
|
|
||||||
|
if ( cp5.isTouch && ( action == MouseEvent.PRESS || action == MouseEvent.RELEASE ) ) {
|
||||||
|
// Use 'Android Mode' which is really just touchscreen support
|
||||||
|
mouseEvent( theMouseEvent.getX( ), theMouseEvent.getY( ), action == MouseEvent.PRESS );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( action == MouseEvent.PRESS ) {
|
||||||
mousePressedEvent( );
|
mousePressedEvent( );
|
||||||
}
|
}
|
||||||
if ( theMouseEvent.getAction( ) == MouseEvent.RELEASE ) {
|
if ( action == MouseEvent.RELEASE ) {
|
||||||
mouseReleasedEvent( );
|
mouseReleasedEvent( );
|
||||||
}
|
}
|
||||||
if ( theMouseEvent.getAction( ) == MouseEvent.WHEEL ) {
|
if ( action == MouseEvent.WHEEL ) {
|
||||||
|
|
||||||
setMouseWheelRotation( theMouseEvent.getCount( ) );
|
setMouseWheelRotation( theMouseEvent.getCount( ) );
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -531,7 +545,7 @@ public final class ControlWindow {
|
|||||||
if ( cp5.blockDraw == false ) {
|
if ( cp5.blockDraw == false ) {
|
||||||
if ( cp5.isAndroid ) {
|
if ( cp5.isAndroid ) {
|
||||||
mouseEvent( cp5.papplet.mouseX , cp5.papplet.mouseY , cp5.papplet.mousePressed );
|
mouseEvent( cp5.papplet.mouseX , cp5.papplet.mouseY , cp5.papplet.mousePressed );
|
||||||
} else {
|
} else if ( !cp5.isTouch ) {
|
||||||
updateEvents( );
|
updateEvents( );
|
||||||
}
|
}
|
||||||
if ( isVisible ) {
|
if ( isVisible ) {
|
||||||
|
Loading…
Reference in New Issue
Block a user