CoreIndependentInputSource class

Applies to Windows and Windows Phone

Surfaces core input APIs for interoperation scenarios.

Syntax


public sealed class CoreIndependentInputSource : ICoreInputSourceBase,
    ICorePointerInputSource

Attributes

[MarshalingBehavior(Agile)]
[Muse()]
[Version(0x06030000)]
[WebHostHidden()]

Members

The CoreIndependentInputSource class has these types of members:

Events

The CoreIndependentInputSource class has these events.

EventDescription
InputEnabled Occurs when input is enabled or disabled for the Windows Store app.
PointerCaptureLost Occurs when a pointer moves to another Windows Store app.
PointerEntered Occurs when a pointer moves into the bounding box of the Windows Store app.
PointerExited Occurs when the pointer moves outside the bounding box of the Windows Store app.
PointerMoved Occurs when a pointer moves within the bounding box of the Windows Store app.
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.
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.
PointerWheelChanged Occurs when the wheel button is rotated.

 

Methods

The CoreIndependentInputSource class has these methods. It also inherits methods from the Object class.

MethodDescription
ReleasePointerCapture Disables pointer capture for the Windows Store app.
SetPointerCapture Enables pointer capture for the Windows Store app.

 

Properties

The CoreIndependentInputSource class has these properties.

PropertyAccess typeDescription

Dispatcher

Read-onlyGets the event dispatcher for the window.

HasCapture

Read-onlyGets a value that reports whether the window has pointer capture.

IsInputEnabled

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

PointerCursor

Read/writeGets or sets the cursor used by the Windows Store app.

PointerPosition

Read-onlyGets the client coordinates of the pointer.

 

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.

Requirements

Minimum supported client

Windows 8.1 [Windows Store apps only]

Minimum supported server

Windows Server 2012 R2 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Runtime apps only]

Namespace

Windows.UI.Core
Windows::UI::Core [C++]

Metadata

Windows.winmd

See also

ICoreInputSourceBase
ICorePointerInputSource
SwapChainPanel
Using the thread pool in Windows Store apps

 

 

Show:
© 2014 Microsoft