Core​Independent​Input​Source Core​Independent​Input​Source Core​Independent​Input​Source Class

Definition

Surfaces core input API for interoperation scenarios.

public : sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSourcepublic sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSourcePublic NotInheritable Class CoreIndependentInputSource Implements ICoreInputSourceBase, ICorePointerInputSource
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Remarks

Create an instance of this class by calling SwapChainBackgroundPanel::CreateCoreIndependentInputSource or SwapChainPanel::CreateCoreIndependentInputSource.

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 from a non-UI thread, otherwise the CreateCoreIndependentInputSource 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 and CoreIndependentInputSource, see the DrawingPanel class definition that is part of the XAML SwapChainPanel DirectX interop sample.

Properties

Dispatcher Dispatcher Dispatcher

Gets the event dispatcher for the window.

public : CoreDispatcher Dispatcher { get; }public CoreDispatcher Dispatcher { get; }Public ReadOnly Property Dispatcher As CoreDispatcher
Value
CoreDispatcher CoreDispatcher CoreDispatcher

The event dispatcher for the window.

Attributes

HasCapture HasCapture HasCapture

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

public : PlatForm::Boolean HasCapture { get; }public bool HasCapture { get; }Public ReadOnly Property HasCapture As bool
Value
PlatForm::Boolean bool bool

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

Attributes
See Also

IsInputEnabled IsInputEnabled IsInputEnabled

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

public : PlatForm::Boolean IsInputEnabled { get; set; }public bool IsInputEnabled { get; set; }Public ReadWrite Property IsInputEnabled As bool
Value
PlatForm::Boolean bool bool

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

Attributes

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 CoreCursor
Value
CoreCursor CoreCursor CoreCursor

The app's cursor.

Attributes

PointerPosition PointerPosition PointerPosition

Gets the client coordinates of the pointer.

public : Point PointerPosition { get; }public Point PointerPosition { get; }Public ReadOnly Property PointerPosition As Point
Value
Point Point Point

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

Attributes

Methods

ReleasePointerCapture() ReleasePointerCapture() ReleasePointerCapture()

Disables pointer capture for the Windows Store app.

public : void ReleasePointerCapture()public void ReleasePointerCapture()Public Function ReleasePointerCapture() As void
Attributes

SetPointerCapture() SetPointerCapture() SetPointerCapture()

Enables pointer capture for the Windows Store app.

public : void SetPointerCapture()public void SetPointerCapture()Public Function SetPointerCapture() As void
Attributes

Remarks

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

Events

InputEnabled InputEnabled InputEnabled

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

public : event TypedEventHandler InputEnabledpublic event TypedEventHandler InputEnabledPublic Event InputEnabled
Attributes

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 PointerCaptureLost
Attributes

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 PointerEntered
Attributes

Remarks

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

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 PointerExited
Attributes

Remarks

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

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 PointerMoved
Attributes

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 PointerPressed
Attributes

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 PointerReleased
Attributes

PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the wheel button is rotated.

public : event TypedEventHandler PointerWheelChangedpublic event TypedEventHandler PointerWheelChangedPublic Event PointerWheelChanged
Attributes

See Also