Skip to content

Size the mark that is selected, and let a caption be reopened - #16

Merged
ursasi merged 1 commit into
mainfrom
fix/caption-edit-and-selection
Oct 26, 2026
Merged

ursasi merged 1 commit into
mainfrom
fix/caption-edit-and-selection

Conversation

@ursasi

@ursasi ursasi commented Oct 26, 2026

Copy link
Copy Markdown
Owner

Three problems, two of them mine from the last round.

1. ⇧⏎ finished the snip instead of breaking the line

NSTextView sends both plain ⏎ and ⇧⏎ as insertNewline, so the "⇧⏎ inserts a line break" branch never ran. The modifier flags decide now; ⌥⏎ works the same way.

2. The wheel resized the wrong mark

It followed "whatever was drawn last", so opening a new caption and scrolling resized the previous one. That was a bad rule:

  • A mark is selected by being drawn, or by being clicked.
  • The size controls (wheel, [ ], − 粗细 N +) act on the selection.
  • With nothing selected they set the value for the next mark.
  • While a caption is being typed, that box counts as the selection and grows as you scroll — it no longer touches anything behind it.

The selected mark is outlined in dashes so it is clear what the wheel will change.

3. A caption could not be edited again

Double-click a caption to reopen it for editing; the words go back into the same mark rather than leaving a duplicate beside it. Drag still moves it, and ⌫ deletes the selected mark.

Verification

check result
⇧⏎ while typing second line added, snip still open
wheel while typing a new caption that box grew (26 → 42), previous marks untouched
double-click an existing caption editor reopened with its text; typing appended, saved PNG shows 原始文字(改过)
click a drawn mark dashed outline shows it is the target

Driving this through synthesised events needs mouseEventClickState set to get a real double-click; otherwise clickCount is always 1, which is why an earlier attempt looked like the feature did not work. The type: debug command now also writes straight into the open caption, because focus-stealing is refused while another app is in front.

Three things about editing a caption, and about what the wheel is changing.

⇧⏎ and ⌥⏎ were meant to break the line, but a text view sends both plain ⏎ and
⇧⏎ as `insertNewline`, so ⇧⏎ finished the snip instead. The modifiers decide now.

The wheel used to follow "whatever was drawn last", so starting a new caption and
scrolling resized the previous one. A mark is now selected — by being drawn, or by
being clicked — and the size controls act on the selection; with nothing selected
they set the value for the next mark. While a caption is being typed that box
counts as the selection, and its own type grows with the wheel.

A caption can also be reopened: double-click it to edit its words, drag it to
move it, ⌫ to delete the selected mark. Re-editing writes back to the same mark
instead of leaving a second copy beside it.
@ursasi
ursasi merged commit 8b09baf into main Oct 26, 2026
1 check passed
@ursasi
ursasi deleted the fix/caption-edit-and-selection branch October 30, 2026 10:47
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.

1 participant