CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource Class

Surfaces core input API for interoperation scenarios.

Syntax

Declaration

public sealed class CoreIndependentInputSourcepublic sealed class CoreIndependentInputSourcePublic NotInheritable Class CoreIndependentInputSource

Remarks

Create an instance of this class by calling CreateCoreIndependentInputSource(CoreInputDeviceTypes) or CreateCoreIndependentInputSource(CoreInputDeviceTypes).

The CoreIndependentInputSource class enables an app to handle input and rendering independent of the XAML UI thread, because you're deliberately providing the input processing logic on a background thread. You must call CreateCoreIndependentInputSource(CoreInputDeviceTypes) from a non-UI thread, otherwise the CreateCoreIndependentInputSource(CoreInputDeviceTypes) method call will fail.

Initializing independent input

// Create a task to register for independent input and begin processing input messages.
auto workItemHandler = ref new WorkItemHandler([this] (IAsyncAction ^)
{
   // The CoreIndependentInputSource will raise pointer events for the specified device types on whichever thread it's created on.
   CoreIndependentInputSource^ coreInput = CreateCoreIndependentInputSource(
      Windows::UI::Core::CoreInputDeviceTypes::Mouse |
      Windows::UI::Core::CoreInputDeviceTypes::Touch |
      Windows::UI::Core::CoreInputDeviceTypes::Pen
   );

   // Register for pointer events, which will be raised on the background thread.
   coreInput->PointerPressed += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerPressed);
   coreInput->PointerMoved += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerMoved);
   coreInput->PointerReleased += ref new TypedEventHandler<Object^, PointerEventArgs^>(this, &MyClass::OnPointerReleased);

   // Begin processing input messages as they're delivered.
   coreInput->Dispatcher->ProcessEvents(CoreProcessEventsOption::ProcessUntilQuit);
});

// Run task on a dedicated high priority background thread.
m_inputLoopWorker = ThreadPool::RunAsync(workItemHandler, WorkItemPriority::High, WorkItemOptions::TimeSliced);

For more example code of how to use CreateCoreIndependentInputSource(CoreInputDeviceTypes) and CoreIndependentInputSource, see the DrawingPanel class definition that is part of the XAML SwapChainPanel DirectX interop sample.

Properties summary

Gets the event dispatcher for the window.

Gets a value that reports whether the window has pointer capture.

Gets or sets a value that indicates whether input is enabled for the Windows Store app.

Gets or sets the cursor used by the Windows Store app.

Gets the client coordinates of the pointer.

Methods summary

Disables pointer capture for the Windows Store app.

Enables pointer capture for the Windows Store app.

Events summary

Occurs when input is enabled or disabled for the Windows Store app.

Occurs when a pointer moves to another Windows Store app. This event is raised after PointerExited and is the final event received by the app for this pointer.

Occurs when a pointer moves into the bounding box of the Windows Store app.

Occurs when the pointer moves outside the bounding box of the Windows Store app.

Occurs when a pointer moves within the bounding box of the Windows Store app.

Occurs when a mouse button is clicked, or a touch or pen contact is detected, within the bounding rectangle of the Windows Store app.

Occurs when a mouse button is released, or a touch or pen contact is lifted, within the bounding rectangle of the Windows Store app.

Occurs when the wheel button is rotated.

Properties

  • Dispatcher
    Dispatcher
    Dispatcher
    Dispatcher

    Gets the event dispatcher for the window.

    public CoreDispatcher Dispatcher { get; }public CoreDispatcher Dispatcher { get; }Public ReadOnly Property Dispatcher As CoreDispatcherpublic CoreDispatcher Dispatcher { get; }

    Property Value

  • HasCapture
    HasCapture
    HasCapture
    HasCapture

    Gets a value that reports whether the window has pointer capture.

    public bool HasCapture { get; }public bool HasCapture { get; }Public ReadOnly Property HasCapture As boolpublic bool HasCapture { get; }

    Property Value

    • bool
      bool
      bool

      true if the window has pointer capture; otherwise, false.

  • IsInputEnabled
    IsInputEnabled
    IsInputEnabled
    IsInputEnabled

    Gets or sets a value that indicates whether input is enabled for the Windows Store app.

    public bool IsInputEnabled { get; set; }public bool IsInputEnabled { get; set; }Public ReadWrite Property IsInputEnabled As boolpublic bool IsInputEnabled { get; set; }

    Property Value

    • bool
      bool
      bool

      true if input is enabled for the app; false if it is disabled.

  • PointerCursor
    PointerCursor
    PointerCursor
    PointerCursor

    Gets or sets the cursor used by the Windows Store app.

    public CoreCursor PointerCursor { get; set; }public CoreCursor PointerCursor { get; set; }Public ReadWrite Property PointerCursor As CoreCursorpublic CoreCursor PointerCursor { get; set; }

    Property Value

  • PointerPosition
    PointerPosition
    PointerPosition
    PointerPosition

    Gets the client coordinates of the pointer.

    public Point PointerPosition { get; }public Point PointerPosition { get; }Public ReadOnly Property PointerPosition As Pointpublic Point PointerPosition { get; }

    Property Value

    • The position of the pointer in device-independent pixel (DIP).

Methods

  • ReleasePointerCapture()
    ReleasePointerCapture()
    ReleasePointerCapture()
    ReleasePointerCapture()

    Disables pointer capture for the Windows Store app.

    public void ReleasePointerCapture()public void ReleasePointerCapture()Public Function ReleasePointerCapture() As voidpublic void ReleasePointerCapture()
  • SetPointerCapture()
    SetPointerCapture()
    SetPointerCapture()
    SetPointerCapture()

    Enables pointer capture for the Windows Store app.

    public void SetPointerCapture()public void SetPointerCapture()Public Function SetPointerCapture() As voidpublic void SetPointerCapture()

    Remarks

    The app must be in the foreground for this method to succeed.

Events

  • InputEnabled
    InputEnabled
    InputEnabled
    InputEnabled

    Occurs when input is enabled or disabled for the Windows Store app.

    public event TypedEventHandler InputEnabledpublic event TypedEventHandler InputEnabledPublic Event InputEnabledpublic event TypedEventHandler InputEnabled
  • PointerCaptureLost
    PointerCaptureLost
    PointerCaptureLost
    PointerCaptureLost

    Occurs when a pointer moves to another Windows Store app. This event is raised after PointerExited and is the final event received by the app for this pointer.

    public event TypedEventHandler PointerCaptureLostpublic event TypedEventHandler PointerCaptureLostPublic Event PointerCaptureLostpublic event TypedEventHandler PointerCaptureLost
  • PointerEntered
    PointerEntered
    PointerEntered
    PointerEntered

    Occurs when a pointer moves into the bounding box of the Windows Store app.

    public event TypedEventHandler PointerEnteredpublic event TypedEventHandler PointerEnteredPublic Event PointerEnteredpublic event TypedEventHandler PointerEntered

    Remarks

    For touch input, the app receives this event before a PointerPressed event.

  • PointerExited
    PointerExited
    PointerExited
    PointerExited

    Occurs when the pointer moves outside the bounding box of the Windows Store app.

    public event TypedEventHandler PointerExitedpublic event TypedEventHandler PointerExitedPublic Event PointerExitedpublic event TypedEventHandler PointerExited

    Remarks

    For touch input, the app receives this event before a PointerReleased event.

  • PointerMoved
    PointerMoved
    PointerMoved
    PointerMoved

    Occurs when a pointer moves within the bounding box of the Windows Store app.

    public event TypedEventHandler PointerMovedpublic event TypedEventHandler PointerMovedPublic Event PointerMovedpublic event TypedEventHandler PointerMoved
  • PointerPressed
    PointerPressed
    PointerPressed
    PointerPressed

    Occurs when a mouse button is clicked, or a touch or pen contact is detected, within the bounding rectangle of the Windows Store app.

    public event TypedEventHandler PointerPressedpublic event TypedEventHandler PointerPressedPublic Event PointerPressedpublic event TypedEventHandler PointerPressed
  • PointerReleased
    PointerReleased
    PointerReleased
    PointerReleased

    Occurs when a mouse button is released, or a touch or pen contact is lifted, within the bounding rectangle of the Windows Store app.

    public event TypedEventHandler PointerReleasedpublic event TypedEventHandler PointerReleasedPublic Event PointerReleasedpublic event TypedEventHandler PointerReleased
  • PointerWheelChanged
    PointerWheelChanged
    PointerWheelChanged
    PointerWheelChanged

    Occurs when the wheel button is rotated.

    public event TypedEventHandler PointerWheelChangedpublic event TypedEventHandler PointerWheelChangedPublic Event PointerWheelChangedpublic event TypedEventHandler PointerWheelChanged

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MarshalingBehaviorAttribute
Windows.Foundation.Metadata.MuseAttribute
Windows.Foundation.Metadata.WebHostHiddenAttribute

Details

Assembly

Windows.UI.Core.dll