View.RequestPointerCapture Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Requests pointer capture mode.
[Android.Runtime.Register("requestPointerCapture", "()V", "GetRequestPointerCaptureHandler", ApiSince=26)]
public virtual void RequestPointerCapture ();
[<Android.Runtime.Register("requestPointerCapture", "()V", "GetRequestPointerCaptureHandler", ApiSince=26)>]
abstract member RequestPointerCapture : unit -> unit
override this.RequestPointerCapture : unit -> unit
- Attributes
Remarks
Requests pointer capture mode.
When the window has pointer capture, the mouse pointer icon will disappear and will not change its position. Enabling pointer capture will change the behavior of input devices in the following ways: <ul> <li>Events from a mouse will be delivered with the source InputDevice#SOURCE_MOUSE_RELATIVE
, and relative position changes will be available through MotionEvent#getX
and MotionEvent#getY
.</li>
<li>Events from a touchpad or trackpad will be delivered with the source InputDevice#SOURCE_TOUCHPAD
, where the absolute position of each of the pointers on the touchpad will be available through MotionEvent#getX(int)
and MotionEvent#getY(int)
, and their relative movements are stored in MotionEvent#AXIS_RELATIVE_X
and MotionEvent#AXIS_RELATIVE_Y
.</li>
<li>Events from other types of devices, such as touchscreens, will not be affected.</li> </ul>
When pointer capture changes, connected mouse and trackpad devices may be reconfigured, and their properties (such as their sources or motion ranges) may change. Use an android.hardware.input.InputManager.InputDeviceListener
to be notified when a device changes (which may happen after enabling or disabling pointer capture), and use InputDevice#getDevice(int)
to get the updated InputDevice
.
Events captured through pointer capture will be dispatched to OnCapturedPointerListener#onCapturedPointer(View, MotionEvent)
if an OnCapturedPointerListener
is set, and otherwise to #onCapturedPointerEvent(MotionEvent)
.
If the window already has pointer capture, this call does nothing.
The capture may be released through #releasePointerCapture()
, or will be lost automatically when the window loses focus.
Java documentation for android.view.View.requestPointerCapture()
.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.