Version: 2023.2
言語: 日本語
Dispatch events
Handle event callbacks and value changes

Capture the pointer with a manipulator

ポインターの入力を処理する場合、コントロールにポインターをキャプチャさせたい場合があります。ビジュアル要素がポインターをキャプチャすると、ポインターがビジュアル要素上にあるかどうかにかかわらず、Unity はポインターに関連するすべてのイベントをビジュアル要素に送信します。例えば、ドラッグイベントを受信するコントロールを作成し、ポインターをキャプチャすると、コントロールはポインターの位置に関係なくドラッグイベントを受信します。

The Manipulator class provides a convenient way to capture the pointer. The Manipulator class is a base class for all manipulators. A manipulator is a class that handles pointer input and sends events to a visual element. For example, the Clickable class is a manipulator that sends a PointerDownEvent when the user clicks on a visual element. After a PointerDownEvent, some elements must capture the pointer position to ensure it receives all subsequent pointer events, even when the cursor is no longer hovering over the element. For example, when you click on a button, slider, or scroll bar.

To capture the pointer, call PointerCaptureHelper.CapturePointer.

To release the pointer, call PointerCaptureHelper.ReleasePointer. If another element is already capturing the pointer when you call CapturePointer(), the element receives a PointerCaptureOutEvent event and loses the capture.

Only one element in the application can have the capture at any moment. While an element has the capture, it’s the target of all subsequent pointer events except mouse wheel events. This only applies to pointer events that don’t already have a set target and rely on the dispatch process to determine the target.

For more information, see the Capture events.

その他の参考資料

Dispatch events
Handle event callbacks and value changes