mirror of
https://github.com/processing/processing4.git
synced 2026-06-16 04:26:26 +02:00
add section to cover changes between core and android.core. also clean up some event methods and variables
This commit is contained in:
@@ -0,0 +1,42 @@
|
||||
[ changes between processing.android.core and processing.core ]
|
||||
|
||||
+ For compatability, mouseX and mouseY work similar to the original API,
|
||||
and always contain the most recent mouse position. In addition, the
|
||||
motionX, motionY, pmotionX, pmotionY, and motionPressure events can be
|
||||
used to track relative motion (the native way Android handles input).
|
||||
Unlike mouseX/mouseY, those variables are also float values.
|
||||
|
||||
+ The mouseButton variable is not available, for obvious reasions.
|
||||
|
||||
+ The keyEvent and mouseEvent variables are not available. If you want to
|
||||
work with event objects, you'll need to override the key and motion handlers:
|
||||
|
||||
public boolean onTouchEvent(MotionEvent event) {
|
||||
// your code here
|
||||
|
||||
// if you want the variables for motionX/motionY, mouseX/mouseY etc.
|
||||
// to work properly, you'll need to call super.onTouchEvent().
|
||||
return super.onTouchEvent(event);
|
||||
}
|
||||
|
||||
The key methods work in a similar fashion:
|
||||
|
||||
public boolean onKeyDown(int code, KeyEvent event) {
|
||||
return super.onKeyDown(code, event);
|
||||
}
|
||||
|
||||
public boolean onKeyUp(int code, KeyEvent event) {
|
||||
return super.onKeyDown(code, event);
|
||||
}
|
||||
|
||||
These three functions behave a bit differently than their counterparts in
|
||||
java.awt, so make sure you know what you're doing before messing with them.
|
||||
|
||||
The reason that the variables are not kept around is because the KeyEvent
|
||||
and MotionEvent objects are reused, which means they can't be reused without
|
||||
an expensive clone operation. And because it's so rare that they're used
|
||||
in Processing code, it's better to simply remove them and let advanced users
|
||||
who would otherwise rely on the events to handle the overrides themselves.
|
||||
|
||||
|
||||
|
||||
@@ -190,7 +190,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
|
||||
public boolean mousePressed;
|
||||
|
||||
public MotionEvent motionEvent;
|
||||
// public MotionEvent motionEvent;
|
||||
|
||||
|
||||
/**
|
||||
@@ -218,7 +218,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
/**
|
||||
* the last KeyEvent object passed into a mouse function.
|
||||
*/
|
||||
public KeyEvent keyEvent;
|
||||
// public KeyEvent keyEvent;
|
||||
|
||||
/**
|
||||
* Gets set to true/false as the applet gains/loses focus.
|
||||
@@ -413,12 +413,15 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
|
||||
protected void onResume() {
|
||||
// TODO need to bring back app state here!
|
||||
// surfaceView.onResume();
|
||||
System.out.println("PApplet.onResume() called");
|
||||
super.onResume();
|
||||
}
|
||||
|
||||
|
||||
protected void onPause() {
|
||||
// TODO need to save all application state here!
|
||||
System.out.println("PApplet.onPause() called");
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@@ -494,6 +497,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
|
||||
|
||||
public void onDestroy() {
|
||||
System.out.println("PApplet.onDestroy() called");
|
||||
super.onDestroy();
|
||||
}
|
||||
|
||||
@@ -651,6 +655,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
* Inform the view that the activity is paused.
|
||||
*/
|
||||
public void onPause() {
|
||||
System.out.println("SurfaceView.onPause() called");
|
||||
//mGLThread.onPause();
|
||||
synchronized (this) {
|
||||
paused = true;
|
||||
@@ -662,6 +667,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
* Inform the view that the activity is resumed.
|
||||
*/
|
||||
public void onResume() {
|
||||
System.out.println("SurfaceView.onResume() called");
|
||||
//mGLThread.onResume();
|
||||
synchronized (this) {
|
||||
paused = false;
|
||||
@@ -713,14 +719,14 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
|
||||
|
||||
public boolean onKeyDown(int code, KeyEvent event) {
|
||||
System.out.println("got onKeyDown for " + code + " " + event);
|
||||
// System.out.println("got onKeyDown for " + code + " " + event);
|
||||
checkKeyEvent(event);
|
||||
return super.onKeyDown(code, event);
|
||||
}
|
||||
|
||||
|
||||
public boolean onKeyUp(int code, KeyEvent event) {
|
||||
System.out.println("got onKeyUp for " + code + " " + event);
|
||||
// System.out.println("got onKeyUp for " + code + " " + event);
|
||||
checkKeyEvent(event);
|
||||
return super.onKeyDown(code, event);
|
||||
}
|
||||
@@ -1929,8 +1935,7 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
protected void dequeueKeyEvents() {
|
||||
synchronized (keyEventQueue) {
|
||||
for (int i = 0; i < keyEventCount; i++) {
|
||||
keyEvent = keyEventQueue[i];
|
||||
handleKeyEvent(keyEvent);
|
||||
handleKeyEvent(keyEventQueue[i]);
|
||||
}
|
||||
keyEventCount = 0;
|
||||
}
|
||||
@@ -1938,7 +1943,6 @@ public class PApplet extends Activity implements PConstants, Runnable {
|
||||
|
||||
|
||||
protected void handleKeyEvent(KeyEvent event) {
|
||||
keyEvent = event;
|
||||
// event.isPrintingKey() returns false for whitespace and others,
|
||||
// which is a problem if the space bar or tab key are used.
|
||||
key = (char) event.getUnicodeChar();
|
||||
|
||||
+3
-1
@@ -27,7 +27,6 @@ P1 _ errors that happen inside events (e.g. keys) not highlighting lines
|
||||
P1 _ useful stack trace information not coming through.. why?
|
||||
P1 _ http://dev.processing.org/bugs/show_bug.cgi?id=1384
|
||||
|
||||
|
||||
P2 _ separate "PApplet" into separate View and Activity classes
|
||||
P2 _ http://dev.processing.org/bugs/show_bug.cgi?id=1398
|
||||
P2 _ too many temporary objects (particularly w/ color) created with A2D
|
||||
@@ -66,3 +65,6 @@ P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1385
|
||||
P3 _ for now, only runs on the first device (findDevice()) found
|
||||
P3 _ --> implement selector to choose the default device for debugging
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1389
|
||||
P3 _ mouseClicked() is currently missing
|
||||
P3 _ implement tap methods to handle mouseClicked()
|
||||
P3 _ http://dev.processing.org/bugs/show_bug.cgi?id=1406
|
||||
|
||||
Reference in New Issue
Block a user