microsoft/microsoft-ui-reactor/reactor-input
Claude Code and agent skill by microsoft/microsoft-ui-reactor
- vendor
Checking that the SKILL.md file is still in the repository.
Reactor input — gestures (`OnPan`, `OnPinch`, `OnRotate`), pointer events, drag-and-drop (`OnDragStarting`), focus management (`UseElementFocus`, `UseFocus`, `UseFocusTrap`). Use when implementing direct manipulation or custom focus behavior.
Install
npx vskill@latest install microsoft/microsoft-ui-reactor/reactor-inputSKILL.md
The same SKILL.md was published earlier as microsoft/microsoft-ui-reactor/reactor-input.
Input and Gestures in Reactor
Reactor exposes input via trampoline-dispatched `.On*` modifiers. Events auto-enable their underlying WinUI flags (ManipulationMode, AllowDrop, etc.) when you attach a handler, so you never need to set those manually.
Controlled prop note: input factories keep the ergonomic(value, setter)shape. The underlying controlled element properties areOptional<T>soUnsetcan mean "control-owned"; direct reads need.Valueor.GetValueOrDefault(...). See
Quick reference
| API | Purpose | |
|---|---|---|
.OnPointerEntered/Exited/Pressed/Released/Moved | Pointer events | |
.IsHitTestVisible(bool) | Opt an element + its subtree out of hit-testing | |
.OnTapped() / .OnDoubleTapped() / .OnRightTapped() | Tap events | |
.OnKeyDown() / .OnKeyUp() | Keyboard events | |
.OnPan(...) | Pan gesture (drag with inertia) | |
.OnPinch(...) | Pinch-to-zoom gesture | |
.OnRotate(...) | Rotation gesture | |
.OnLongPress(...) | Press-and-hold | |
.OnGotFocus() / .OnLostFocus() | Focus change events | |
UseElementFocus() | Untyped ref + dispatcher-scheduled focus | |
UseElementRef<T>() | Typed element ref — .Current is T (no cast) | |
.XYFocusUp/Down/Left/Right(ref) | Directional focus reference props | |
.AccessKey("S") | Alt+key keyboard shortcut | |
.OnDragStart(...) / .OnDrop(...) | Drag-and-drop |
1. Pointer events
<!-- index:pointer-input --> Pointer handlers attach like any other modifier; Reactor installs one stable trampoline per element, so re-rendering with a fresh closure costs no re-subscription.
Events: OnPointerEntered, OnPointerExited, OnPointerPressed, OnPointerReleased, OnPointerMoved, OnPointerCanceled.
The (s, e) signature gives you the sender and PointerRoutedEventArgs.
Opting out of hit-testing
.IsHitTestVisible(false) sets UIElement.IsHitTestVisible — the element and its subtree stop being pointer targets, so decorative or overlay layers let pointer events pass through to whatever is underneath.
Unlike .IsEnabled(false), it does not grey the control out or block focus — reach for .IsEnabled(false) when you want a disabled affordance, and .IsHitTestVisible(false) when you only want clicks to fall through.
2. Tap events
Border and other non-control elements are not tab stops by default: a Border with .OnTapped(...) answers the mouse but is skipped by the keyboard. Add .IsTabStop(true) and an .OnKeyDown Enter/Space handler, or use a Button, whenever the gesture is a real command.
<!-- /index:pointer-input -->
3. Keyboard events
<!-- index:keyboard-input --> Attach .OnKeyDown / .OnKeyUp to any element. The handler receives (sender, KeyRoutedEventArgs); set e.Handled = true to stop the event bubbling. .OnPreviewKeyDown / .OnPreviewKeyUp run first, during the tunnelling phase, and can swallow a key before the focused control sees it.
`e.Key` is `Windows.System.VirtualKey` — WinRT, not WPF. It is not System.Windows.Input.Key, and the member names differ: VirtualKey has no OemPeriod, OemPlus, OemMinus or Equal. Punctuation and OEM keys simply have no named member. Two ways to handle them:
Named members you can rely on are the letters (VirtualKey.A), digits (VirtualKey.Number0, VirtualKey.NumberPad0), the numpad operators (Add, Subtract, Multiply, Divide, Decimal), and the editing and navigation keys (Enter, Space, Back, Escape, Tab, Delete, Left, Right, Up, Down).
Ctrl/Alt chords do not belong on `.OnKeyDown`. A handler on a TextBox only fires while that field has focus, so an app-wide shortcut written that way silently does nothing elsewhere. Use a Command with an Accelerator, which registers with WinUI's accelerator infrastructure. The REACTOR_INPUT_001 analyzer flags the mistake.
Mind the scope, though: an accelerator fires when the surface carrying it is in the focused element's ancestor chain, so Button(save) on its own covers the button, not the window. CommandHost([save], subtree) widens it to a whole subtree, and a MenuBar or CommandBar at the window root is what makes a chord genuinely window-wide — those attach to the window's KeyboardAccelerators collection. See commanding. <!-- /index:keyboard-input -->
4. Continuous gestures (Pan, Pinch, Rotate)
<!-- index:pointer-input --> Gestures follow a phase lifecycle: Began → Changed (repeat) → Ended | Cancelled. Attaching a gesture handler auto-enables the underlying ManipulationMode, so you never set that yourself.
Pan gesture
Smooth drags (performance-critical)
.Translation(...) puts the position on the composition visual, and each pan event re-renders the component. Two rules keep the card under the pointer:
- Build the position from the cumulative `e.Translation`, plus the position
at the last gesture end, as above. Don't write setOffset(offset + e.Delta): offset is the value from the last render, so an event that arrives before the next render loses its movement. rest is safe to read in onEnded because it only changes between gestures.
- Keep the per-event render small. A small component keeps up with the
pointer at every pan event. One that re-renders a lot of UI per event falls behind, because Reactor renders at DispatcherQueuePriority.Low after a render that took longer than a frame. Move the draggable element into its own component so a pan re-renders only that element.
Don't mix `el.Translation` with `.Translation(...)`. Pick one per element. Reactor enables translation on the composition visual only when the element declares .Translation(...), a translation: keyframe or an .InteractionStates(...) translation, and once it is enabled WinUI silently ignores el.Translation writes. Code that writes el.Translation through an ElementRef (from UseElementRef<T>; .Ref(...) doesn't accept a UseRef box) keeps working next to .Scale(...), .Rotation(...) or .Animate(...) (a pressed-card .Scale(pressed ? 0.97f : 1) is fine), but not next to .Translation(...), and REACTOR_ANIM_004 flags .Set(fe => fe.Translation = ...) on a chain that declares it. The same goes for reading back: el.Scale and el.Rotation read identity once a transform modifier has taken the visual.
Pinch and Rotate
Both gestures carry an absolute value and a per-event delta as flat doubles — Scale/ScaleDelta and Angle/AngleDelta. There is no nested e.Delta object on these two.
5. Long press
Touch/pen has built-in long press; mouse requires emulation:
<!-- /index:pointer-input -->
6. Focus management
<!-- index:element-refs --> An ElementRef is the bridge from the declarative tree to a realized WinUI element. Attach it with .Ref(...), then read .Current — it is null until the element mounts, survives re-renders, and clears on unmount, so the same cell reliably points at whatever is mounted now.
UseElementFocus
UseElementFocus returns a handle with .Ref (attach to the element) and .RequestFocus() (imperatively focus it). It is a named tuple, so the deconstructed form is equivalent and is what the guide uses — RequestFocus schedules the focus on the UI dispatcher, so it is safe to call from an effect that runs before the element has mounted:
For a synchronous attempt, or one whose success you need to observe, call Microsoft.UI.Reactor.Input.FocusManager.Focus(inputRef) or FocusManager.FocusAsync(inputRef) instead.
UseElementRef\<T\> — typed refs
When you actually need to call methods on the underlying control (SelectAll() on a TextBox, Focus(FocusState.Programmatic), etc.), use the typed variant. .Current is already typed as T — no cast at the call site:
The constraint is T : FrameworkElement. In DEBUG builds Reactor asserts the actual mounted element is a T; in release the mismatch is silent and .Current returns null. Spec 033 §3.
XYFocus reference props
Use XYFocus refs for gamepad/keyboard directional navigation graphs. The target can mount before or after the referrer; Reactor rewrites the WinUI UIElement.XYFocus* property when the referenced element becomes available and clears it when that element unmounts.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 100 of 100Pattern checks on the skill's files. Certified 3 Oct 2026.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingplugins/reactor/skills/reactor-input/SKILL.md
Popularity
- Repository stars
- 660
- Repository forks
- 57
- 7-day trend score
- 32
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/microsoft/microsoft-ui-reactor/reactor-input)