Trim needless comments and fix the picker width
Remove comments that only restate the code, keeping the section banners and the notes that carry a reason, a measured fact or an external contract. ButtonOptions.width claimed to be a fixed width but only set minWidth, so the Graph and Texture pickers grew with the name they showed. It is now what it promises, with a separate minWidth for the buttons that have two forms. Narrow buttons shrink their padding, otherwise a 24px icon button had 8px left for its glyph and truncate dropped it entirely. __gm.labelsDropped() guards that class: the overflow guard only saw text that was too wide, never a label truncated to nothing. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
1 parent
f16801aef3
commit
4d84231b9f
115 files changed
+707
-1564
No files matched your search
@@ -1,17 +1,15 @@
|
||||
/**
|
||||
* The one piece of DOM in the whole application: an invisible, off-screen `<input>` that
|
||||
* receives keyboard focus while a canvas text field is being edited. The browser supplies
|
||||
* IME composition, the mobile on-screen keyboard, clipboard and selection semantics; the
|
||||
* canvas field mirrors `value` / selection from here. Nothing visible is DOM.
|
||||
* The one piece of DOM in the application: an invisible `<input>` that holds keyboard focus while
|
||||
* a canvas text field is edited, so the browser supplies IME, clipboard, selection and the mobile
|
||||
* keyboard. The canvas field mirrors its value and selection.
|
||||
*/
|
||||
|
||||
/** A canvas text field while it is being edited; the bridge forwards the input's events to it. */
|
||||
export interface TextEditTarget {
|
||||
/** Called whenever value or selection changed. */
|
||||
onBridgeInput(value: string, selectionStart: number, selectionEnd: number): void;
|
||||
/** Called for navigation keys (Enter, Escape, Tab, arrows …). Return true to consume. */
|
||||
onBridgeKey(event: KeyboardEvent): boolean;
|
||||
/** The bridge lost DOM focus (user clicked elsewhere, window blur). */
|
||||
/** The bridge lost DOM focus. */
|
||||
onBridgeBlur(): void;
|
||||
}
|
||||
|
||||
@@ -65,7 +63,7 @@ export class KeyboardBridge {
|
||||
});
|
||||
}
|
||||
|
||||
/** Start editing: mirror the field's value into the input and grab DOM focus. */
|
||||
/** Mirrors the field's value into the input and grabs DOM focus. */
|
||||
attach(
|
||||
target: TextEditTarget,
|
||||
value: string,
|
||||
@@ -86,21 +84,18 @@ export class KeyboardBridge {
|
||||
this.input.style.top = `${Math.max(0, y)}px`;
|
||||
}
|
||||
|
||||
/**
|
||||
* Push a value/selection the canvas side changed (arrow stepping, caret placement) into the
|
||||
* input, so the next keystroke edits the same text the user sees.
|
||||
*/
|
||||
/** Pushes a value the canvas side changed into the input, so the next keystroke edits that text. */
|
||||
setValue(value: string, selectionStart = value.length, selectionEnd = selectionStart): void {
|
||||
this.input.value = value;
|
||||
if (document.activeElement === this.input) this.input.setSelectionRange(selectionStart, selectionEnd);
|
||||
}
|
||||
|
||||
/** Selects the whole input; the field learns about it through the usual `onBridgeInput` sync. */
|
||||
/** The field learns about it through the usual `onBridgeInput` sync. */
|
||||
selectAll(): void {
|
||||
this.input.select();
|
||||
}
|
||||
|
||||
/** Stop editing for `target`. Ignored when another field attached meanwhile, so a late blur cannot steal it. */
|
||||
/** Ignored when another field attached meanwhile, so a late blur cannot steal it. */
|
||||
detach(target: TextEditTarget): void {
|
||||
if (this.target !== target) return;
|
||||
this.target = null;
|
||||
|
||||
Reference in new issue
Block a user