Example usage for android.support.v4.view InputDeviceCompat SOURCE_MOUSE

List of usage examples for android.support.v4.view InputDeviceCompat SOURCE_MOUSE

Introduction

In this page you can find the example usage for android.support.v4.view InputDeviceCompat SOURCE_MOUSE.

Prototype

int SOURCE_MOUSE

To view the source code for android.support.v4.view InputDeviceCompat SOURCE_MOUSE.

Click Source Link

Document

The input source is a mouse pointing device.

Usage

From source file:android.support.v13.view.DragStartHelper.java

/**
 * Handle a touch event.// w  ww.  ja v  a 2 s. c  om
 * @param v The view the touch event has been dispatched to.
 * @param event The MotionEvent object containing full information about
 *        the event.
 * @return True if the listener has consumed the event, false otherwise.
 */
public boolean onTouch(View v, MotionEvent event) {
    if (event.getAction() == MotionEvent.ACTION_DOWN || event.getAction() == MotionEvent.ACTION_MOVE) {
        mLastTouchX = (int) event.getX();
        mLastTouchY = (int) event.getY();
    }
    if (event.getAction() == MotionEvent.ACTION_MOVE
            && MotionEventCompat.isFromSource(event, InputDeviceCompat.SOURCE_MOUSE)
            && (MotionEventCompat.getButtonState(event) & MotionEventCompat.BUTTON_PRIMARY) != 0) {
        return mListener.onDragStart(v, this);
    }
    return false;
}