共用方式為


InputPointerSource 類別

定義

表示註冊至報表指標輸入的物件,並提供指標資料指標和輸入事件處理。

public ref class InputPointerSource sealed : InputObject
/// [Windows.Foundation.Metadata.ContractVersion(Microsoft.Foundation.WindowsAppSDKContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class InputPointerSource final : InputObject
[Windows.Foundation.Metadata.ContractVersion(typeof(Microsoft.Foundation.WindowsAppSDKContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class InputPointerSource : InputObject
Public NotInheritable Class InputPointerSource
Inherits InputObject
繼承
Object Platform::Object IInspectable InputObject InputPointerSource
屬性

範例

下列範例示範如何使用CreateCoreIndependentInputSource設定SwapChainPanel,並透過DispatcherQueueController接收背景執行緒上的低延遲畫筆和觸控輸入。

void SetupBackgroundPenInput(SwapChainPanel swapChainPanel)
{
    m_dispatcherQueueController = DispatcherQueueController::CreateOnDedicatedThread();

    m_dispatcherQueueController.DispatcherQueue().TryEnqueue([this] {

        InputPointerSourceDeviceKinds deviceKind = (InputPointerSourceDeviceKinds)(
            Microsoft::UI::Input::InputPointerSourceDeviceKinds::Touch |
            Microsoft::UI::Input::InputPointerSourceDeviceKinds::Pen);
        m_coreInput = swapChainPanel().CreateCoreIndependentInputSource(deviceKind);

        m_coreInput.PointerMoved({ this, &DirectXPage::SwapChainPanel_OnPointerMoved });
        });
}


void DirectXPage::SwapChainPanel_OnPointerPressed(InputPointerSource const& sender, Microsoft::UI::Input::PointerEventArgs const& e)
{
    // When the pointer is pressed begin tracking the pointer movement.
    m_main->StartTracking();
}

此範例示範如何設定系統手部游標影像,以在游標停留在 SwapChainPanel 上時顯示:

InputPointerSourceDeviceKinds deviceKind = (InputPointerSourceDeviceKinds)(
    Microsoft::UI::Input::InputPointerSourceDeviceKinds::Touch |
    Microsoft::UI::Input::InputPointerSourceDeviceKinds::Mouse |
    Microsoft::UI::Input::InputPointerSourceDeviceKinds::Pen);
m_coreInput = swapChainPanel().CreateCoreIndependentInputSource(deviceKind);

m_coreInput.InputCursor = InputSystemCursor.Create(InputSystemCursorShape.Hand);

備註

指標事件的座標空間與 SwapChainPanel 物件位於相同的座標空間中。

事件順序

一般大小寫

InputPointerSource 的指標事件會遵循正常情況下的保證順序:

  1. PointerEntered
  2. PointerPressed
  3. PointerMoved
  4. PointerReleased
  5. PointerExited

只有在指標移動或滑鼠變更上的按鈕狀態時, 才會引發 PointerMoved 。 所有事件都有相同的指標識別碼。

指標擷取遺失

當連入指標由輸入系統路由傳送至不同的輸入目標時,會引發 PointerCaptureLost。 引發 PointerCaptureLost 時,只有在收到 PointerPressed 之後才會發生,該指標不會引發任何其他事件。 具體而言,不會引發 PointerReleasedPointerExited ,因此您應該處理 PointerCaptureLost 做為指定指標的有效結束狀態。 以下是包含遺失指標擷取的有效事件序列範例:

  1. PointerEntered
  2. PointerPressed
  3. PointerMoved
  4. PointerCaptureLost

路由事件

當連入指標路由傳送至輸入系統不同的輸入目標時,就會引發指標路由事件。 不同于 PointerCaptureLost,路由事件提供在釋放指標之前,連絡內指標傳回的可能性。

以下顯示有效的事件序列,其中連絡內指標會路由傳送至不同的目標、路由回原始 InputPointerSource,然後釋放:

  1. PointerEntered
  2. PointerPressed
  3. PointerMoved
  4. PointerRoutedAway
  5. PointerRoutedTo
  6. PointerReleased
  7. PointerExited

以下是有效的事件序列範例,其中連絡指標會路由傳送至不同的目標,然後在另一個目標上釋放:

  1. PointerEntered
  2. PointerPressed
  3. PointerMoved
  4. PointerRoutedAway
  5. PointerRoutedReleased

注意

當 PointerRoutedReleased 引發時,將不會針對該指標引發其他事件。 具體而言,不會引發 PointerReleasedPointerExited ,因此您應該處理 PointerRoutedReleased 做為指定指標的有效結束狀態。

您也可以接收從不同目標路由傳送的全新連絡內指標。 在此情況下,如果目前 InputPointerSource 尚未看到指標,則 PointerEnteredPointerPressed 事件保證在 PointerRoutedTo 之前。 以下是此事件序列的範例:

  1. PointerEntered
  2. PointerPressed
  3. PointerRoutedTo
  4. PointerMoved
  5. PointerReleased
  6. PointerExited

屬性

Cursor

取得或設定當滑鼠或畫筆指標位於此InputPointerSource的輸入目標上方、VisualWindowId (HWND) 時所顯示的游標。

DeviceKinds

取得這個 InputPointerSource支援的裝置類型。

DispatcherQueue

取得 InputObject 的 DispatcherQueue

(繼承來源 InputObject)

方法

GetForIsland(ContentIsland)

InputPointerSource 取指定 ContentIsland的物件。

事件

PointerCaptureLost

發生于與此 InputPointerSource 接觸的指標移至另一個輸入目標時。

PointerEntered

當指標移至這個 InputPointerSource的界限時發生。

PointerExited

發生于指標移出這個 InputPointerSource的界限時。

PointerMoved

當指標在這個 InputPointerSource的範圍內移動時發生。

PointerPressed

發生于按下滑鼠按鍵,或手指或手寫筆起始與數位板表面的接觸時,同時在這個 InputPointerSource的範圍內。

PointerReleased

發生于先前起始按下動作的指標裝置放開時, (放開滑鼠按鍵,或從數位板介面) 增益觸控或手寫筆接觸,而在這個 InputPointerSource的範圍內。

PointerRoutedAway

當指標重新導向至另一個 InputPointerSource (可能位於個別進程) 時發生。

PointerRoutedReleased

發生于路由傳送至不同 InputPointerSource 的指標在其他輸入目標上釋放時。

PointerRoutedTo

當指標從不同的輸入目標路由至這個 InputPointerSource 時發生。

PointerWheelChanged

發生于滾輪旋轉 (滾輪差異值變更) 時。

適用於

另請參閱