CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource 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// This API is not available in Javascript.
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 Dispatcher

Gets the event dispatcher for the window.

public : CoreDispatcher Dispatcher { get; }public CoreDispatcher Dispatcher { get; }Public ReadOnly Property Dispatcher As CoreDispatcher// This API is not available in Javascript.
Value
CoreDispatcher CoreDispatcher CoreDispatcher CoreDispatcher

The event dispatcher for the window.

HasCapture 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// This API is not available in Javascript.
Value
PlatForm::Boolean bool bool bool

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

See Also

IsInputEnabled 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// This API is not available in Javascript.
Value
PlatForm::Boolean 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 CoreCursor// This API is not available in Javascript.
Value
CoreCursor CoreCursor CoreCursor CoreCursor

The app's cursor.

PointerPosition PointerPosition PointerPosition PointerPosition

Gets the client coordinates of the pointer.

public : Point PointerPosition { get; }public Point PointerPosition { get; }Public ReadOnly Property PointerPosition As Point// This API is not available in Javascript.
Value
Point Point Point Point

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 void// This API is not available in Javascript.

SetPointerCapture() SetPointerCapture() SetPointerCapture() SetPointerCapture()

Enables pointer capture for the Windows Store app.

public : void SetPointerCapture()public void SetPointerCapture()Public Function SetPointerCapture() As void// This API is not available in Javascript.

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 InputEnabled<object,  InputEnabledEventArgs>public event TypedEventHandler InputEnabled<object,  InputEnabledEventArgs>Public Event InputEnabled<object,  InputEnabledEventArgs>// This API is not available in Javascript.

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 PointerCaptureLost<object,  PointerEventArgs>public event TypedEventHandler PointerCaptureLost<object,  PointerEventArgs>Public Event PointerCaptureLost<object,  PointerEventArgs>// This API is not available in Javascript.

PointerEntered PointerEntered PointerEntered PointerEntered

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

public : event TypedEventHandler PointerEntered<object,  PointerEventArgs>public event TypedEventHandler PointerEntered<object,  PointerEventArgs>Public Event PointerEntered<object,  PointerEventArgs>// This API is not available in Javascript.

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 PointerExited<object,  PointerEventArgs>public event TypedEventHandler PointerExited<object,  PointerEventArgs>Public Event PointerExited<object,  PointerEventArgs>// This API is not available in Javascript.

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 PointerMoved<object,  PointerEventArgs>public event TypedEventHandler PointerMoved<object,  PointerEventArgs>Public Event PointerMoved<object,  PointerEventArgs>// This API is not available in Javascript.

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 PointerPressed<object,  PointerEventArgs>public event TypedEventHandler PointerPressed<object,  PointerEventArgs>Public Event PointerPressed<object,  PointerEventArgs>// This API is not available in Javascript.

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 PointerReleased<object,  PointerEventArgs>public event TypedEventHandler PointerReleased<object,  PointerEventArgs>Public Event PointerReleased<object,  PointerEventArgs>// This API is not available in Javascript.

PointerWheelChanged PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the wheel button is rotated.

public : event TypedEventHandler PointerWheelChanged<object,  PointerEventArgs>public event TypedEventHandler PointerWheelChanged<object,  PointerEventArgs>Public Event PointerWheelChanged<object,  PointerEventArgs>// This API is not available in Javascript.

See Also