Loading core/java/android/app/Activity.java +11 −6 Original line number Diff line number Diff line Loading @@ -3999,13 +3999,12 @@ public class Activity extends ContextThemeWrapper /** * Called when a touch screen event was not handled by any of the views * under it. This is most useful to process touch events that happen * inside of the activity. This is most useful to process touch events that happen * outside of your window bounds, where there is no view to receive it. * * @param event The touch screen event being processed. * * @return Return true if you have consumed the event, false if you haven't. * The default implementation always returns false. */ public boolean onTouchEvent(MotionEvent event) { if (mWindow.shouldCloseOnTouch(this, event)) { Loading Loading @@ -4038,12 +4037,12 @@ public class Activity extends ContextThemeWrapper * Called when a generic motion event was not handled by any of the * views inside of the activity. * <p> * Generic motion events describe joystick movements, mouse hovers, track pad * touches, scroll wheel movements and other input events. The * {@link MotionEvent#getSource() source} of the motion event specifies * Generic motion events describe joystick movements, hover events from mouse or stylus * devices, trackpad touches, scroll wheel movements and other motion events not handled * by {@link #onTouchEvent(MotionEvent)} or {@link #onTrackballEvent(MotionEvent)}. * The {@link MotionEvent#getSource() source} of the motion event specifies * the class of input that was received. Implementations of this method * must examine the bits in the source before processing the event. * The following code example shows how this is done. * </p><p> * Generic motion events with source class * {@link android.view.InputDevice#SOURCE_CLASS_POINTER} Loading Loading @@ -4254,6 +4253,8 @@ public class Activity extends ContextThemeWrapper * @param ev The touch screen event. * * @return boolean Return true if this event was consumed. * * @see #onTouchEvent(MotionEvent) */ public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { Loading @@ -4274,6 +4275,8 @@ public class Activity extends ContextThemeWrapper * @param ev The trackball event. * * @return boolean Return true if this event was consumed. * * @see #onTrackballEvent(MotionEvent) */ public boolean dispatchTrackballEvent(MotionEvent ev) { onUserInteraction(); Loading @@ -4292,6 +4295,8 @@ public class Activity extends ContextThemeWrapper * @param ev The generic motion event. * * @return boolean Return true if this event was consumed. * * @see #onGenericMotionEvent(MotionEvent) */ public boolean dispatchGenericMotionEvent(MotionEvent ev) { onUserInteraction(); Loading core/java/android/view/View.java +28 −8 Original line number Diff line number Diff line Loading @@ -310,7 +310,7 @@ import java.util.function.Predicate; * </tr> * * <tr> * <td rowspan="4">Event processing</td> * <td rowspan="6">Event processing</td> * <td><code>{@link #onKeyDown(int, KeyEvent)}</code></td> * <td>Called when a new hardware key event occurs. * </td> Loading @@ -330,6 +330,16 @@ import java.util.function.Predicate; * <td>Called when a touch screen motion event occurs. * </td> * </tr> * <tr> * <td><code>{@link #onGenericMotionEvent(MotionEvent)}</code></td> * <td>Called when a generic motion event occurs. * </td> * </tr> * <tr> * <td><code>{@link #onHoverEvent(MotionEvent)}</code></td> * <td>Called when a hover motion event occurs. * </td> * </tr> * * <tr> * <td rowspan="2">Focus</td> Loading Loading @@ -15077,6 +15087,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onTouchEvent(MotionEvent) */ public boolean dispatchTouchEvent(MotionEvent event) { // If the event should be handled by accessibility focus first. Loading Loading @@ -15171,6 +15183,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onTrackballEvent(MotionEvent) */ public boolean dispatchTrackballEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -15205,11 +15219,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Generic motion events with source class {@link InputDevice#SOURCE_CLASS_POINTER} * are delivered to the view under the pointer. All other generic motion events are * delivered to the focused view. Hover events are handled specially and are delivered * to {@link #onHoverEvent(MotionEvent)}. * to {@link #onHoverEvent(MotionEvent)} first. * </p> * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onHoverEvent(MotionEvent) * @see #onGenericMotionEvent(MotionEvent) */ public boolean dispatchGenericMotionEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -16040,13 +16057,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** * Implement this method to handle trackball motion events. The * <em>relative</em> movement of the trackball since the last event * Implement this method to handle trackball motion events. * <p> * The <em>relative</em> movement of the trackball since the last event * can be retrieve with {@link MotionEvent#getX MotionEvent.getX()} and * {@link MotionEvent#getY MotionEvent.getY()}. These are normalized so * that a movement of 1 corresponds to the user pressing one DPAD key (so * they will often be fractional values, representing the more fine-grained * movement information available from a trackball). * </p> * * @param event The motion event. * @return True if the event was handled, false otherwise. Loading @@ -16058,9 +16077,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Implement this method to handle generic motion events. * <p> * Generic motion events describe joystick movements, mouse hovers, track pad * touches, scroll wheel movements and other input events. The * {@link MotionEvent#getSource() source} of the motion event specifies * Generic motion events describe joystick movements, hover events from mouse or stylus * devices, trackpad touches, scroll wheel movements and other motion events not handled * by {@link #onTouchEvent(MotionEvent)} or {@link #onTrackballEvent(MotionEvent)}. * The {@link MotionEvent#getSource() source} of the motion event specifies * the class of input that was received. Implementations of this method * must examine the bits in the source before processing the event. * The following code example shows how this is done. Loading @@ -16079,7 +16099,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { * switch (event.getAction()) { * case MotionEvent.ACTION_HOVER_MOVE: * // process the mouse hover movement... * // process the hover movement... * return true; * case MotionEvent.ACTION_SCROLL: * // process the scroll wheel movement... Loading
core/java/android/app/Activity.java +11 −6 Original line number Diff line number Diff line Loading @@ -3999,13 +3999,12 @@ public class Activity extends ContextThemeWrapper /** * Called when a touch screen event was not handled by any of the views * under it. This is most useful to process touch events that happen * inside of the activity. This is most useful to process touch events that happen * outside of your window bounds, where there is no view to receive it. * * @param event The touch screen event being processed. * * @return Return true if you have consumed the event, false if you haven't. * The default implementation always returns false. */ public boolean onTouchEvent(MotionEvent event) { if (mWindow.shouldCloseOnTouch(this, event)) { Loading Loading @@ -4038,12 +4037,12 @@ public class Activity extends ContextThemeWrapper * Called when a generic motion event was not handled by any of the * views inside of the activity. * <p> * Generic motion events describe joystick movements, mouse hovers, track pad * touches, scroll wheel movements and other input events. The * {@link MotionEvent#getSource() source} of the motion event specifies * Generic motion events describe joystick movements, hover events from mouse or stylus * devices, trackpad touches, scroll wheel movements and other motion events not handled * by {@link #onTouchEvent(MotionEvent)} or {@link #onTrackballEvent(MotionEvent)}. * The {@link MotionEvent#getSource() source} of the motion event specifies * the class of input that was received. Implementations of this method * must examine the bits in the source before processing the event. * The following code example shows how this is done. * </p><p> * Generic motion events with source class * {@link android.view.InputDevice#SOURCE_CLASS_POINTER} Loading Loading @@ -4254,6 +4253,8 @@ public class Activity extends ContextThemeWrapper * @param ev The touch screen event. * * @return boolean Return true if this event was consumed. * * @see #onTouchEvent(MotionEvent) */ public boolean dispatchTouchEvent(MotionEvent ev) { if (ev.getAction() == MotionEvent.ACTION_DOWN) { Loading @@ -4274,6 +4275,8 @@ public class Activity extends ContextThemeWrapper * @param ev The trackball event. * * @return boolean Return true if this event was consumed. * * @see #onTrackballEvent(MotionEvent) */ public boolean dispatchTrackballEvent(MotionEvent ev) { onUserInteraction(); Loading @@ -4292,6 +4295,8 @@ public class Activity extends ContextThemeWrapper * @param ev The generic motion event. * * @return boolean Return true if this event was consumed. * * @see #onGenericMotionEvent(MotionEvent) */ public boolean dispatchGenericMotionEvent(MotionEvent ev) { onUserInteraction(); Loading
core/java/android/view/View.java +28 −8 Original line number Diff line number Diff line Loading @@ -310,7 +310,7 @@ import java.util.function.Predicate; * </tr> * * <tr> * <td rowspan="4">Event processing</td> * <td rowspan="6">Event processing</td> * <td><code>{@link #onKeyDown(int, KeyEvent)}</code></td> * <td>Called when a new hardware key event occurs. * </td> Loading @@ -330,6 +330,16 @@ import java.util.function.Predicate; * <td>Called when a touch screen motion event occurs. * </td> * </tr> * <tr> * <td><code>{@link #onGenericMotionEvent(MotionEvent)}</code></td> * <td>Called when a generic motion event occurs. * </td> * </tr> * <tr> * <td><code>{@link #onHoverEvent(MotionEvent)}</code></td> * <td>Called when a hover motion event occurs. * </td> * </tr> * * <tr> * <td rowspan="2">Focus</td> Loading Loading @@ -15077,6 +15087,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onTouchEvent(MotionEvent) */ public boolean dispatchTouchEvent(MotionEvent event) { // If the event should be handled by accessibility focus first. Loading Loading @@ -15171,6 +15183,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onTrackballEvent(MotionEvent) */ public boolean dispatchTrackballEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -15205,11 +15219,14 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * Generic motion events with source class {@link InputDevice#SOURCE_CLASS_POINTER} * are delivered to the view under the pointer. All other generic motion events are * delivered to the focused view. Hover events are handled specially and are delivered * to {@link #onHoverEvent(MotionEvent)}. * to {@link #onHoverEvent(MotionEvent)} first. * </p> * * @param event The motion event to be dispatched. * @return True if the event was handled by the view, false otherwise. * * @see #onHoverEvent(MotionEvent) * @see #onGenericMotionEvent(MotionEvent) */ public boolean dispatchGenericMotionEvent(MotionEvent event) { if (mInputEventConsistencyVerifier != null) { Loading Loading @@ -16040,13 +16057,15 @@ public class View implements Drawable.Callback, KeyEvent.Callback, } /** * Implement this method to handle trackball motion events. The * <em>relative</em> movement of the trackball since the last event * Implement this method to handle trackball motion events. * <p> * The <em>relative</em> movement of the trackball since the last event * can be retrieve with {@link MotionEvent#getX MotionEvent.getX()} and * {@link MotionEvent#getY MotionEvent.getY()}. These are normalized so * that a movement of 1 corresponds to the user pressing one DPAD key (so * they will often be fractional values, representing the more fine-grained * movement information available from a trackball). * </p> * * @param event The motion event. * @return True if the event was handled, false otherwise. Loading @@ -16058,9 +16077,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback, /** * Implement this method to handle generic motion events. * <p> * Generic motion events describe joystick movements, mouse hovers, track pad * touches, scroll wheel movements and other input events. The * {@link MotionEvent#getSource() source} of the motion event specifies * Generic motion events describe joystick movements, hover events from mouse or stylus * devices, trackpad touches, scroll wheel movements and other motion events not handled * by {@link #onTouchEvent(MotionEvent)} or {@link #onTrackballEvent(MotionEvent)}. * The {@link MotionEvent#getSource() source} of the motion event specifies * the class of input that was received. Implementations of this method * must examine the bits in the source before processing the event. * The following code example shows how this is done. Loading @@ -16079,7 +16099,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback, * if (event.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) { * switch (event.getAction()) { * case MotionEvent.ACTION_HOVER_MOVE: * // process the mouse hover movement... * // process the hover movement... * return true; * case MotionEvent.ACTION_SCROLL: * // process the scroll wheel movement...