CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource CoreIndependentInputSource Class

Definition

Some information relates to pre-released product which may be substantially modified before it’s commercially released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

Prerelease APIs are identified by a Prerelease label.

[Contains prerelease APIs.]
Surfaces core input API for interoperation scenarios.

public : sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
struct winrt::Windows::UI::Core::CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
public sealed class CoreIndependentInputSource : ICoreInputSourceBase, ICorePointerInputSource
Public 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 Dispatcher

Gets the event dispatcher for the window.

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

The CoreDispatcher for the window.

DispatcherQueue DispatcherQueue DispatcherQueue DispatcherQueue

Prerelease. Gets the DispatcherQueue associated with this CoreIndependentInputSource.

public : DispatcherQueue DispatcherQueue { get; }
DispatcherQueue DispatcherQueue();
public DispatcherQueue DispatcherQueue { get; }
Public ReadOnly Property DispatcherQueue As DispatcherQueue
Value
DispatcherQueue DispatcherQueue

The DispatcherQueue for managing prioritized tasks that execute in a serial fashion on a thread.

Additional features and requirements
Device family
Windows 10 Insider Preview (introduced v10.0.17095.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v6)

Remarks

Some platform objects require thread affinity for posting events back to the thread where the object was instantiated. The DispatcherQueue lets you post work to this thread.

These platform objects can be created on the UI thread, where the DispatcherQueue already exists, or they can be created on a long running, non-UI thread with a DispatcherQueue created with the DispatcherQueueController.CreateOnDedicatedThread method.

HasCapture HasCapture HasCapture HasCapture

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

public : Platform::Boolean HasCapture { get; }
bool HasCapture();
public bool HasCapture { get; }
Public ReadOnly Property HasCapture As bool
Value
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 UWP app.

public : Platform::Boolean IsInputEnabled { get; set; }
bool IsInputEnabled(); void IsInputEnabled(bool isinputenabled);
public bool IsInputEnabled { get; set; }
Public ReadWrite Property IsInputEnabled As bool
Value
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 UWP app.

public : CoreCursor PointerCursor { get; set; }
CoreCursor PointerCursor(); void PointerCursor(CoreCursor pointercursor);
public CoreCursor PointerCursor { get; set; }
Public ReadWrite Property PointerCursor As CoreCursor
Value
CoreCursor CoreCursor

The app's cursor.

PointerPosition PointerPosition PointerPosition PointerPosition

Gets the client coordinates of the pointer.

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

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

Methods

ReleasePointerCapture() ReleasePointerCapture() ReleasePointerCapture() ReleasePointerCapture()

Disables pointer capture for the UWP app.

public : void ReleasePointerCapture()
void ReleasePointerCapture() const;
public void ReleasePointerCapture()
Public Function ReleasePointerCapture() As void

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

Enables pointer capture for the UWP app.

public : void SetPointerCapture()
void SetPointerCapture() const;
public void SetPointerCapture()
Public Function SetPointerCapture() As void

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 UWP app.

public : event TypedEventHandler InputEnabled<Platform::Object, InputEnabledEventArgs>
// Register
event_token InputEnabled(TypedEventHandler<Platform::Object, InputEnabledEventArgs> const& handler) const;

// Revoke with event_token
void InputEnabled(event_token const& cookie) const;

// Revoke with event_revoker
InputEnabled_revoker InputEnabled(auto_revoker_t, TypedEventHandler<Platform::Object, InputEnabledEventArgs> const& handler) const;
public event TypedEventHandler InputEnabled<object, InputEnabledEventArgs>
Public Event TypedEventHandler InputEnabled( Of ( Of object ), ( Of InputEnabledEventArgs ))

PointerCaptureLost PointerCaptureLost PointerCaptureLost PointerCaptureLost

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

public : event TypedEventHandler PointerCaptureLost<Platform::Object, PointerEventArgs>
// Register
event_token PointerCaptureLost(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerCaptureLost(event_token const& cookie) const;

// Revoke with event_revoker
PointerCaptureLost_revoker PointerCaptureLost(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerCaptureLost<object, PointerEventArgs>
Public Event TypedEventHandler PointerCaptureLost( Of ( Of object ), ( Of PointerEventArgs ))

PointerEntered PointerEntered PointerEntered PointerEntered

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

public : event TypedEventHandler PointerEntered<Platform::Object, PointerEventArgs>
// Register
event_token PointerEntered(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerEntered(event_token const& cookie) const;

// Revoke with event_revoker
PointerEntered_revoker PointerEntered(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerEntered<object, PointerEventArgs>
Public Event TypedEventHandler PointerEntered( Of ( Of object ), ( Of PointerEventArgs ))

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 UWP app.

public : event TypedEventHandler PointerExited<Platform::Object, PointerEventArgs>
// Register
event_token PointerExited(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerExited(event_token const& cookie) const;

// Revoke with event_revoker
PointerExited_revoker PointerExited(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerExited<object, PointerEventArgs>
Public Event TypedEventHandler PointerExited( Of ( Of object ), ( Of PointerEventArgs ))

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 UWP app.

public : event TypedEventHandler PointerMoved<Platform::Object, PointerEventArgs>
// Register
event_token PointerMoved(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerMoved(event_token const& cookie) const;

// Revoke with event_revoker
PointerMoved_revoker PointerMoved(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerMoved<object, PointerEventArgs>
Public Event TypedEventHandler PointerMoved( Of ( Of object ), ( Of PointerEventArgs ))

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 UWP app.

public : event TypedEventHandler PointerPressed<Platform::Object, PointerEventArgs>
// Register
event_token PointerPressed(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerPressed(event_token const& cookie) const;

// Revoke with event_revoker
PointerPressed_revoker PointerPressed(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerPressed<object, PointerEventArgs>
Public Event TypedEventHandler PointerPressed( Of ( Of object ), ( Of PointerEventArgs ))

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 UWP app.

public : event TypedEventHandler PointerReleased<Platform::Object, PointerEventArgs>
// Register
event_token PointerReleased(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerReleased(event_token const& cookie) const;

// Revoke with event_revoker
PointerReleased_revoker PointerReleased(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerReleased<object, PointerEventArgs>
Public Event TypedEventHandler PointerReleased( Of ( Of object ), ( Of PointerEventArgs ))

PointerWheelChanged PointerWheelChanged PointerWheelChanged PointerWheelChanged

Occurs when the wheel button is rotated.

public : event TypedEventHandler PointerWheelChanged<Platform::Object, PointerEventArgs>
// Register
event_token PointerWheelChanged(TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;

// Revoke with event_token
void PointerWheelChanged(event_token const& cookie) const;

// Revoke with event_revoker
PointerWheelChanged_revoker PointerWheelChanged(auto_revoker_t, TypedEventHandler<Platform::Object, PointerEventArgs> const& handler) const;
public event TypedEventHandler PointerWheelChanged<object, PointerEventArgs>
Public Event TypedEventHandler PointerWheelChanged( Of ( Of object ), ( Of PointerEventArgs ))

See Also