Chord: arm anchor on left double-click so dblclick -> chord flows

A double-click's second press arrives as MouseButtonDblClick, not a plain
press, so m_leftDownInView was never set and the still-held button could not
anchor a chord. Set the chord anchor on a left double-click inside the view
(bracket- or word-select), letting the user proceed directly from a
double-click into a left+middle (Cut) or left+right (Paste) chord without
releasing. All 5 ctest suites green.
This commit is contained in:
Levi Neely 2026-10-07 17:28:14 +02:00
parent a804dbe521
commit 5439d43ac4
2 changed files with 13 additions and 4 deletions

View File

@ -150,6 +150,9 @@ Therefore the palette is replaced, not extended, and the replacement is built on
(`characterAt`), scans with depth counting across line ends, and sets the (`characterAt`), scans with depth counting across line ends, and sets the
selection. When no bracket is adjacent it falls through to Kate's default selection. When no bracket is adjacent it falls through to Kate's default
double-click (word select). double-click (word select).
- A left double-click leaves the button held, so it also arms the chord anchor:
the user can go straight from a double-click (bracket- or word-select) into a
left+middle / left+right chord without releasing.
### M5 — Command vocabulary + project model + switchers — NEXT ### M5 — Command vocabulary + project model + switchers — NEXT
- `:`-verb pack via `KTextEditor::Command`: `sort`, `align`, `json`, `b64`, - `:`-verb pack via `KTextEditor::Command`: `sort`, `align`, `json`, `b64`,

View File

@ -494,15 +494,21 @@ bool OllieView::eventFilter(QObject *obj, QEvent *event)
{ {
// Bracket-pair selection: double-clicking next to a bracket selects the // Bracket-pair selection: double-clicking next to a bracket selects the
// text between the matching pair (multi-line). Falls through to Kate's // text between the matching pair (multi-line). Falls through to Kate's
// default double-click (word select) when no bracket is adjacent. // default double-click (word select) when no bracket is adjacent. The
// second click of a double-click arrives as DblClick (not a plain press)
// and leaves the left button held, so it also arms the chord anchor —
// letting the user go straight from a double-click into a mouse chord.
if (event->type() == QEvent::MouseButtonDblClick) { if (event->type() == QEvent::MouseButtonDblClick) {
auto *mev = static_cast<QMouseEvent *>(event); auto *mev = static_cast<QMouseEvent *>(event);
if (mev->button() == Qt::LeftButton) { if (mev->button() == Qt::LeftButton) {
KTextEditor::View *v = m_mainWindow->activeView(); KTextEditor::View *v = m_mainWindow->activeView();
auto *w = qobject_cast<QWidget *>(obj); auto *w = qobject_cast<QWidget *>(obj);
if (v && w && v->isAncestorOf(w) const bool inView = v && w && v->isAncestorOf(w);
&& selectBracketPairAt(v, mev->globalPosition().toPoint())) { if (inView) {
return true; // handled: suppress default word-select m_leftDownInView = true; // held after the dblclick: chord anchor
if (selectBracketPairAt(v, mev->globalPosition().toPoint())) {
return true; // handled: suppress default word-select
}
} }
} }
} }