Skip to content

Add Ctrl+Enter/Esc and drag-handle reorder to LET to LAMBDA editor#102

Merged
jimmytacks merged 2 commits into
mainfrom
issue-101-editor-keyboard-and-dragdrop
Apr 22, 2026
Merged

Add Ctrl+Enter/Esc and drag-handle reorder to LET to LAMBDA editor#102
jimmytacks merged 2 commits into
mainfrom
issue-101-editor-keyboard-and-dragdrop

Conversation

@jimmytacks
Copy link
Copy Markdown
Collaborator

@jimmytacks jimmytacks commented Apr 22, 2026

Summary

  • Ctrl+Enter saves (when validation passes); Esc cancels — both via a window-level PreviewKeyDown handler in LetToLambdaWindow.
  • The ▲/▼ move buttons on each input row are replaced with a drag handle (⋮⋮) on the left of each kept row.
  • Drag/drop is minimal and in-window: source must be a kept row, drop target must be a kept row. Unchecked rows refuse the drop, so the existing kept-rows-first invariant is preserved without additional bookkeeping.
  • Alt+Up / Alt+Down keyboard reorder still works (and is now the only Move… code path the row template references, alongside drag/drop and the existing Keep-toggle reposition).

Took the custom approach (~80 lines) rather than adding gong-wpf-dragdrop as a dependency — happy to switch if the UX falls short.

Test plan

Unit tests pass (433 / 433). Drag/drop and the new shortcuts are WPF UI behaviour that needs Excel + a real STA window, so manual checks:

  • Open Edit Lambda or LET to LAMBDA and confirm the row template renders the new drag handle on the left and no ▲/▼ buttons on the right
  • Drag a kept row up/down by the handle; row reorders, the rest of the list reflows
  • Drag onto an unchecked row → cursor shows "no-drop"; drop is rejected
  • Uncheck a row → its handle disappears and it can no longer be dragged
  • Alt+Up / Alt+Down still reorders the focused kept row
  • Ctrl+Enter saves only when the Save button is enabled (try with an empty/invalid Lambda name → no-op; with a valid name → saves and closes)
  • Esc closes the dialog with no result

Closes #101

🤖 Generated with Claude Code

jimmytacks and others added 2 commits April 22, 2026 09:16
Ctrl+Enter saves (when validation passes) and Esc cancels via a
window-level PreviewKeyDown handler.

The ▲/▼ move buttons are replaced with a drag handle (⋮⋮) on the
left of each kept row. A minimal in-window drag/drop initiates on the
handle and only allows drops between kept rows, so the
kept-rows-first invariant is preserved without extra bookkeeping.
Alt+Up / Alt+Down keyboard reorder still works.

Closes #101

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Replace the custom mouse handlers + DragOver/Drop wiring with
gong-wpf-dragdrop's attached properties on the InputsList
ItemsControl. The library provides the drag preview ghost and
insertion-line adorner out of the box, which were noticeably absent
in the custom implementation.

KeptRowReorderHandler enforces the kept-rows-only constraint by
implementing IDragSource (refuses to start drag on unchecked rows)
and overriding DefaultDropHandler.DragOver (refuses drop unless both
source and target are kept). DefaultDropHandler.Drop already does
the correct ObservableCollection.Move for same-collection reorders.

DragSourceIgnore on the TextBox / CheckBoxes preserves text
selection and click-to-toggle on those controls.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@jimmytacks
Copy link
Copy Markdown
Collaborator Author

Switched to gong-wpf-dragdrop (3.2.x) per discussion — the library handles the insertion-line adorner and drag-preview ghost natively, which were the missing UX in the custom implementation.

Changes in 90c5698:

  • Added gong-wpf-dragdrop package reference
  • InputsList gets dd:DragDrop.IsDragSource / IsDropTarget / UseDefaultDragAdorner
  • TextBox and CheckBoxes marked dd:DragDrop.DragSourceIgnore so text selection / clicks still work
  • New KeptRowReorderHandler (single class implementing both IDragSource and extending DefaultDropHandler) enforces the kept-rows-only rule on both ends; DefaultDropHandler.Drop does the ObservableCollection.Move
  • All custom mouse-handler / DragOver / Drop code is gone (~100 fewer lines)
  • _rows.CollectionChanged hook now drives UpdateSaveEnabled after a Move

Net diff: −95 lines, +72 lines including the handler class and a single new import. Build clean, 433/433 unit tests pass. Same manual test plan as the original PR description.

@jimmytacks jimmytacks merged commit 967a1fb into main Apr 22, 2026
1 check passed
@jimmytacks jimmytacks deleted the issue-101-editor-keyboard-and-dragdrop branch April 22, 2026 09:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

LET to LAMBDA editor: keyboard shortcuts and drag/drop reorder

1 participant