drawnui-react 0.1.0-preview.36 → 0.1.0-preview.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +87 -13
  2. package/SKIPPED.md +6 -5
  3. package/dist/controls/AnimatedFramesRenderer.d.ts +2 -0
  4. package/dist/controls/AnimatedFramesRenderer.js +2 -0
  5. package/dist/controls/DrawnGame.d.ts +5 -1
  6. package/dist/controls/DrawnGame.js +22 -4
  7. package/dist/controls/SkiaCarousel.d.ts +1 -1
  8. package/dist/controls/SkiaCarousel.js +36 -4
  9. package/dist/controls/SkiaDrawer.d.ts +13 -0
  10. package/dist/controls/SkiaDrawer.js +40 -7
  11. package/dist/controls/SkiaEditor.d.ts +3 -1
  12. package/dist/controls/SkiaEditor.js +5 -0
  13. package/dist/controls/SkiaGif.d.ts +4 -0
  14. package/dist/controls/SkiaGif.js +13 -2
  15. package/dist/controls/SkiaImage.d.ts +5 -0
  16. package/dist/controls/SkiaImage.js +33 -4
  17. package/dist/controls/SkiaLabel.d.ts +7 -1
  18. package/dist/controls/SkiaLabel.js +9 -3
  19. package/dist/controls/SkiaLayout.js +3 -1
  20. package/dist/controls/SkiaLottie.js +1 -1
  21. package/dist/controls/SkiaRadioButton.d.ts +2 -0
  22. package/dist/controls/SkiaRadioButton.js +10 -0
  23. package/dist/controls/SkiaScroll.js +18 -9
  24. package/dist/controls/SkiaShaderCarousel.d.ts +6 -1
  25. package/dist/controls/SkiaShaderCarousel.js +22 -5
  26. package/dist/controls/SkiaSprite.d.ts +3 -0
  27. package/dist/controls/SkiaSprite.js +18 -10
  28. package/dist/controls/SkiaSvg.d.ts +4 -0
  29. package/dist/controls/SkiaSvg.js +27 -3
  30. package/dist/controls/SnappingLayout.js +2 -1
  31. package/dist/core/Accessibility.d.ts +41 -5
  32. package/dist/core/Accessibility.js +190 -9
  33. package/dist/core/Canvas.d.ts +49 -2
  34. package/dist/core/Canvas.js +152 -11
  35. package/dist/core/Gestures.d.ts +47 -0
  36. package/dist/core/Gestures.js +93 -0
  37. package/dist/core/ImageEffects.d.ts +2 -0
  38. package/dist/core/ImageEffects.js +2 -0
  39. package/dist/core/KeyboardManager.d.ts +20 -0
  40. package/dist/core/KeyboardManager.js +58 -15
  41. package/dist/core/PopupWindows.d.ts +2 -0
  42. package/dist/core/PopupWindows.js +2 -0
  43. package/dist/core/SkiaControl.d.ts +31 -1
  44. package/dist/core/SkiaControl.js +61 -5
  45. package/dist/core/Tooltips.d.ts +2 -0
  46. package/dist/core/Tooltips.js +10 -0
  47. package/dist/react/SkiaShell.js +32 -12
  48. package/dist/react/index.d.ts +4 -1
  49. package/dist/react/index.js +34 -16
  50. package/dist/react/reconciler.d.ts +18 -0
  51. package/dist/react/reconciler.js +31 -1
  52. package/package.json +16 -2
@@ -1,4 +1,6 @@
1
1
  import { SKRect } from "./Types";
2
+ /** Controls with `AccessibilityModal` set, on every canvas (drawnui-cross 6av). Empty: no modal work at all. */
3
+ export const AccessibilityModals = new Set();
2
4
  /** ARIA role constants (DrawnUi.Models.Aria) for `AccessibilityRole`. */
3
5
  export const Aria = {
4
6
  // interactive widgets
@@ -168,7 +170,7 @@ export class SkiaAccessibilityManager {
168
170
  /**
169
171
  * Moves keyboard focus between the items of the group around `focused`, by item index like a native list: Down / Up in
170
172
  * a Column, Right / Left in a Row, all four in a Wrap, a Grid or a Split layout (Up / Down by one row), Home / End to the
171
- * first / last item, PageDown / PageUp by one viewport of the scroll around it. No wrap at the ends. The target is the
173
+ * first / last item, PageDown / PageUp by one viewport of the scroll around it. The ends stop the arrows, unless the group has KeyboardWrap. The target is the
172
174
  * item itself when it is an interactive node, else its first interactive node; items the pointer cannot use are
173
175
  * skipped. An item not realized (recycled cells) is scrolled in with ScrollToIndex when the group is the scroll's
174
176
  * content, and focused once drawn. True when the key belongs to the group.
@@ -178,6 +180,28 @@ export class SkiaAccessibilityManager {
178
180
  if (!found)
179
181
  return false;
180
182
  const { Holder: group, Item: item } = found;
183
+ // a menu, list or radio group whose items are not the children of one layout (a panel with a title, a divider and
184
+ // columns of items): its items in reading order, one after another (drawnui-cross 6ao rule 1b, as DrawnUi.Rust)
185
+ const role = found.Group.AccessibilityRole;
186
+ const linear = role === Aria.RoleMenu || role === Aria.RoleMenuBar || role === Aria.RoleList || role === Aria.RoleListBox || role === Aria.RoleRadioGroup;
187
+ const holdsMany = (child) => this.Snapshot.filter((n) => n.CanInteract && IsInside(n.Source, child)).length > 1;
188
+ if (linear && item !== focused && ViewsOf(group).some(holdsMany)) {
189
+ const items = this.Snapshot.filter((n) => n.CanInteract && SkiaAccessibilityManager.TryFindGroup(n.Source)?.Group === found.Group).map((n) => n.Source);
190
+ const current = items.indexOf(focused);
191
+ if (current < 0)
192
+ return false;
193
+ const n = items.length, wrap = found.Group.KeyboardWrap || group.KeyboardWrap;
194
+ const target = key === "ArrowDown" || key === "ArrowRight" ? (wrap ? (current + 1) % n : Math.min(current + 1, n - 1))
195
+ : key === "ArrowUp" || key === "ArrowLeft" ? (wrap ? (current - 1 + n) % n : Math.max(current - 1, 0))
196
+ : key === "Home" ? 0 : key === "End" ? n - 1 : -1;
197
+ if (target < 0)
198
+ return false;
199
+ if (target !== current) {
200
+ this.RequestKeyboardFocus(items[target]);
201
+ found.Group.Superview?.Update();
202
+ }
203
+ return true;
204
+ }
181
205
  const scroll = FindScroll(group), axis = AxisOf(group), count = ItemCount(group);
182
206
  const current = this.groupRequest?.Group === group ? this.groupRequest.Index : IndexOf(group, item);
183
207
  if (current < 0 || count < 1)
@@ -225,6 +249,9 @@ export class SkiaAccessibilityManager {
225
249
  }
226
250
  else
227
251
  return false;
252
+ // KeyboardWrap on the group: the arrows go round, the last item to the first and back
253
+ if ((target < 0 || target >= count) && key.startsWith("Arrow") && (found.Group.KeyboardWrap || group.KeyboardWrap))
254
+ target = target < 0 ? count - 1 : 0;
228
255
  if (target < 0 || target >= count || target === current)
229
256
  return true; // at the end of the group nothing happens, the key still belongs to it
230
257
  this.groupRequest = { Group: group, Scroll: scroll, Index: target, Step: step, Deadline: performance.now() + 3000, ScrollIssued: false };
@@ -234,13 +261,95 @@ export class SkiaAccessibilityManager {
234
261
  // ---- keyboard focus moved by popup windows (drawnui-cross 6ao rule 2, and back to the opener on close) ----
235
262
  focusRequest;
236
263
  popupFocusRoot;
264
+ focusAnyInside = false;
237
265
  /** The keyboard goes to this control at the end of the next frame (a popup closed: back to what opened it). */
238
- RequestKeyboardFocus(control) { this.focusRequest = control; }
266
+ RequestKeyboardFocus(control) { if (!this.appFocusThisFrame)
267
+ this.focusRequest = control; }
268
+ appFocus;
269
+ appFocusDeadline = 0;
270
+ appFocusThisFrame = false; // until the frame end: the app said where the focus goes, the library's moves give way
271
+ clearFocusRequest = false;
272
+ /**
273
+ * App code moves the keyboard and screen-reader focus at the end of the next frame (C# DrawnView.SetAccessibilityFocus,
274
+ * Rust `Cx::set_accessibility_focus`), for a custom menu that moves its highlight: to `control`, which gets it once
275
+ * drawn, within 3 seconds. It wins over the library's own moves in the same frame (a group's arrow move, a closed popup
276
+ * window giving the keyboard back to its opener); undefined cancels a move still waiting, the focus stays where it is.
277
+ * The focus ring shows only if the keyboard is in use (the browser's focus-visible).
278
+ */
279
+ SetAccessibilityFocus(control) {
280
+ this.appFocusThisFrame = true;
281
+ this.focusRequest = undefined;
282
+ this.groupRequest = undefined;
283
+ this.appFocus = control;
284
+ this.appFocusDeadline = performance.now() + 3000;
285
+ control?.Superview?.Update();
286
+ }
239
287
  /**
240
- * While set, Tab stays inside this control: only its nodes are Tab stops and Tab / Shift+Tab go round them. The canvas
241
- * sets it to the top popup window that takes input (a menu, a dropdown), undefined when none is open.
288
+ * No drawn control keeps the keyboard and screen-reader focus (C# KeyboardFocusNode = null): at the end of the next
289
+ * frame the DOM focus goes back to the canvas and the keys belong to the app again.
242
290
  */
243
- KeyboardScope;
291
+ ClearKeyboardFocus() { this.appFocus = undefined; this.clearFocusRequest = true; }
292
+ ProcessAppFocus(scale, w, h, requestFrame) {
293
+ const wanted = this.appFocus;
294
+ if (wanted.IsDisposed || performance.now() > this.appFocusDeadline) {
295
+ this.appFocus = undefined;
296
+ return;
297
+ }
298
+ this.Rebuild(scale, w, h);
299
+ if (!this.Snapshot.some((n) => n.Source === wanted)) {
300
+ requestFrame();
301
+ return;
302
+ } // not drawn yet: look again next frame
303
+ this.appFocus = undefined;
304
+ this.Focus(wanted);
305
+ }
306
+ popupScope;
307
+ /**
308
+ * While set, Tab stays inside this control: only its nodes are Tab stops and Tab / Shift+Tab go round them: the top
309
+ * popup window that takes input (a menu, a dropdown; set by the canvas), else the active modal.
310
+ */
311
+ get KeyboardScope() { return this.popupScope ?? this.ActiveModal; }
312
+ set KeyboardScope(v) { this.popupScope = v; }
313
+ // ---- modal accessibility scope (drawnui-cross 6av, C# AccessibilityModal) ----
314
+ /** The modal that accessibility is limited to: the topmost `AccessibilityModal` control that shows. Undefined when none. */
315
+ ActiveModal;
316
+ // where the keyboard was when each modal became active, to go back there when it goes
317
+ modalReturns = new Map();
318
+ /** A control behind the active modal (not in it, not in a popup window over it): no focus for navigation. */
319
+ IsOutsideModal(control) {
320
+ const modal = this.ActiveModal;
321
+ return !!modal && !IsInside(control, modal) && TopRoot(control) === TopRoot(modal);
322
+ }
323
+ /** Frame end, only while some control is flagged modal or one was active: follows the top modal. */
324
+ UpdateActiveModal() {
325
+ let next;
326
+ for (const m of AccessibilityModals) {
327
+ if (m.IsDisposed || !m.IsVisible || m.Opacity <= 0 || AccessibilityManagerHiddenByAncestor(m)
328
+ || m.Superview?.AccessibilityManager !== this || !IsDrawn(m))
329
+ continue;
330
+ if (!next || IsDrawnAbove(m, next))
331
+ next = m;
332
+ }
333
+ const previous = this.ActiveModal;
334
+ if (previous === next)
335
+ return;
336
+ this.ActiveModal = next;
337
+ this.ForceRebuildOnNextFrame(); // readers and Tab switch to the new scope in this frame
338
+ const keyboard = this.FocusedNode;
339
+ if (next && keyboard && !IsInside(keyboard, next)) {
340
+ // the keyboard is in use: into the modal, and back here when it goes
341
+ this.modalReturns.set(next, keyboard);
342
+ this.popupFocusRoot = next;
343
+ this.focusAnyInside = true;
344
+ }
345
+ const back = previous && this.modalReturns.get(previous);
346
+ if (previous)
347
+ this.modalReturns.delete(previous);
348
+ // back unless the keyboard went elsewhere meanwhile; a keyboard node that left with the modal (disposed, detached) was in it
349
+ const leftWithIt = !!keyboard && (keyboard.IsDisposed || !keyboard.Superview);
350
+ if (back && (!keyboard || leftWithIt || IsInside(keyboard, previous)) && (!next || IsInside(back, next)))
351
+ this.RequestKeyboardFocus(back);
352
+ }
244
353
  /** The Tab stop after (or before) `from` in reading order; inside a KeyboardScope it goes round, never leaving. */
245
354
  NextTabStop(from, forward) {
246
355
  const stops = this.Snapshot.filter((n) => n.CanInteract && this.IsTabStop(n.Source)).map((n) => n.Source);
@@ -258,7 +367,7 @@ export class SkiaAccessibilityManager {
258
367
  * A popup window just opened: at the end of the frame that draws it, the keyboard goes to its arrow-key group's current
259
368
  * choice (a checked radio, menuitemradio, option or tab), else to its first interactive item, however it was opened.
260
369
  */
261
- FocusOpenedPopup(root) { this.popupFocusRoot = root; }
370
+ FocusOpenedPopup(root) { this.popupFocusRoot = root; this.focusAnyInside = false; }
262
371
  ProcessFocusRequests(scale, w, h) {
263
372
  const request = this.focusRequest, root = this.popupFocusRoot;
264
373
  this.focusRequest = this.popupFocusRoot = undefined;
@@ -268,7 +377,8 @@ export class SkiaAccessibilityManager {
268
377
  if (p === root)
269
378
  return true; return false; };
270
379
  const choice = (role) => role === Aria.RoleRadio || role === Aria.RoleMenuItemRadio || role === "option" || role === "tab";
271
- const items = this.Snapshot.filter((n) => n.CanInteract && inside(n.Source) && SkiaAccessibilityManager.TryFindGroup(n.Source));
380
+ // a popup: the items of its arrow-key group; a modal: its first control that takes input
381
+ const items = this.Snapshot.filter((n) => n.CanInteract && inside(n.Source) && (this.focusAnyInside || SkiaAccessibilityManager.TryFindGroup(n.Source)));
272
382
  const target = items.find((n) => n.IsPressed === true && choice(n.Role)) ?? items[0];
273
383
  if (target) {
274
384
  this.FocusFromKeyboard(target.Source, scale, w, h);
@@ -315,6 +425,9 @@ export class SkiaAccessibilityManager {
315
425
  }
316
426
  FocusFromKeyboard(node, scale, w, h) {
317
427
  this.Rebuild(scale, w, h); // the overlay looks the node up in the snapshot: make sure it is there now
428
+ this.Focus(node);
429
+ }
430
+ Focus(node) {
318
431
  this.NoteFocus(node);
319
432
  this.FocusedNode = node;
320
433
  for (const cb of this.keyboardFocusRequested)
@@ -329,6 +442,14 @@ export class SkiaAccessibilityManager {
329
442
  for (const cb of this.liveUpdated)
330
443
  cb(node);
331
444
  }
445
+ /** What the last snapshot says for each live region, to rebuild on the next frame when that changes. */
446
+ liveSaid = new Map();
447
+ LiveChanged() {
448
+ for (const [control, said] of this.liveSaid)
449
+ if (!control.IsDisposed && (control.AccessibilityLabel ?? "") !== said)
450
+ return true;
451
+ return false;
452
+ }
332
453
  ForceRebuildOnNextFrame() { this.lastRebuild = -Infinity; this.dirty = true; }
333
454
  Unregister(node) {
334
455
  if (this.nodes.delete(node)) {
@@ -350,13 +471,29 @@ export class SkiaAccessibilityManager {
350
471
  * per MinUpdateIntervalMs otherwise (keeps rects in sync with scrolling); notifies only when the snapshot differs.
351
472
  */
352
473
  OnFrameEnd(scale, canvasWidthPx, canvasHeightPx, requestFrame) {
474
+ if (AccessibilityModals.size > 0 || this.ActiveModal)
475
+ this.UpdateActiveModal();
353
476
  this.ProcessGroupFocus(scale, canvasWidthPx, canvasHeightPx, requestFrame);
477
+ if (this.clearFocusRequest) {
478
+ this.clearFocusRequest = false;
479
+ this.FocusedNode = undefined;
480
+ for (const cb of this.keyboardFocusRequested)
481
+ cb(undefined);
482
+ }
483
+ if (this.appFocus)
484
+ this.ProcessAppFocus(scale, canvasWidthPx, canvasHeightPx, requestFrame);
354
485
  if (this.focusRequest || this.popupFocusRoot)
355
486
  this.ProcessFocusRequests(scale, canvasWidthPx, canvasHeightPx);
487
+ this.appFocusThisFrame = false;
356
488
  if (this.nodes.size === 0 && this.Snapshot.length === 0)
357
489
  return;
358
490
  const now = performance.now();
359
491
  const wait = this.MinUpdateIntervalMs - (now - this.lastRebuild);
492
+ // a live region whose text changed is read on the next frame, not at the next timed rebuild (accessibility-plan B2)
493
+ if (wait > 0 && this.liveSaid.size > 0 && this.LiveChanged()) {
494
+ this.Rebuild(scale, canvasWidthPx, canvasHeightPx);
495
+ return;
496
+ }
360
497
  if (wait > 0) {
361
498
  // rate-limited: rendering is on demand, so make sure a frame comes back once the interval has passed
362
499
  if (!this.pending)
@@ -369,6 +506,7 @@ export class SkiaAccessibilityManager {
369
506
  this.dirty = false;
370
507
  this.lastRebuild = performance.now();
371
508
  let list = [];
509
+ const modal = this.ActiveModal;
372
510
  for (const n of this.nodes) {
373
511
  if (!n.Superview) {
374
512
  this.nodes.delete(n);
@@ -377,6 +515,8 @@ export class SkiaAccessibilityManager {
377
515
  } // detached from the tree
378
516
  if (!n.IsVisible || !n.IsAccessibilityElement || n.AccessibilityRole === Aria.RolePresentation)
379
517
  continue;
518
+ if (modal && this.IsOutsideModal(n))
519
+ continue; // a modal is shown: only its nodes, and those of popup windows over it
380
520
  if (AccessibilityManagerHiddenByAncestor(n))
381
521
  continue; // e.g. the root page kept mounted under a pushed shell page
382
522
  const px = n.GetAccessibilityPixelRect();
@@ -389,7 +529,7 @@ export class SkiaAccessibilityManager {
389
529
  list.push({
390
530
  Id: n.AccessibilityId, Label: n.AccessibilityLabel, Hint: n.AccessibilityHint, Role: n.AccessibilityRole, Value: n.AccessibilityValue,
391
531
  Rect: new SKRect(px.Left / scale, px.Top / scale, px.Right / scale, px.Bottom / scale),
392
- CanInteract: n.AccessibilityCanInteract, IsPressed: n.AccessibilityIsPressed, Live: n.AccessibilityLive, Source: n,
532
+ CanInteract: n.AccessibilityCanInteract, IsPressed: n.AccessibilityIsPressed, Expanded: n.AccessibilityExpanded, Live: n.AccessibilityLive, Source: n,
393
533
  Disabled: !n.AccessibilityCanInteract && Aria.IsInteractiveRole(n.AccessibilityRole),
394
534
  TextLines: n.AccessibilityTextSelectable ? n.GetAccessibilityTextLines(scale) : undefined,
395
535
  });
@@ -411,6 +551,11 @@ export class SkiaAccessibilityManager {
411
551
  }
412
552
  start = i;
413
553
  }
554
+ this.liveSaid.clear();
555
+ // the control's own name (a name given to a child that says it is no change)
556
+ for (const n of list)
557
+ if (n.Live)
558
+ this.liveSaid.set(n.Source, n.Source.AccessibilityLabel ?? "");
414
559
  if (SkiaAccessibilityManager.Same(list, this.Snapshot))
415
560
  return;
416
561
  this.Snapshot = list;
@@ -423,7 +568,7 @@ export class SkiaAccessibilityManager {
423
568
  for (let i = 0; i < a.length; i++) {
424
569
  const x = a[i], y = b[i];
425
570
  if (x.Source !== y.Source || x.Label !== y.Label || x.Hint !== y.Hint || x.Role !== y.Role || x.CanInteract !== y.CanInteract || x.Disabled !== y.Disabled
426
- || x.IsPressed !== y.IsPressed || x.Live !== y.Live || !SameValue(x.Value, y.Value)
571
+ || x.IsPressed !== y.IsPressed || x.Expanded !== y.Expanded || x.Live !== y.Live || !SameValue(x.Value, y.Value)
427
572
  || Math.abs(x.Rect.Left - y.Rect.Left) > 0.5 || Math.abs(x.Rect.Top - y.Rect.Top) > 0.5
428
573
  || Math.abs(x.Rect.Right - y.Rect.Right) > 0.5 || Math.abs(x.Rect.Bottom - y.Rect.Bottom) > 0.5)
429
574
  return false;
@@ -458,6 +603,9 @@ function SayNamesOnce(list) {
458
603
  owner = bySource.get(p);
459
604
  if (!owner || owner.Label !== x.Label)
460
605
  continue;
606
+ // a dialog keeps its name though its title says it too: readers announce the dialog by name on entry
607
+ if (owner.Role === Aria.RoleDialog || owner.Role === Aria.RoleAlertDialog)
608
+ continue;
461
609
  if (owner.CanInteract)
462
610
  said.add(x);
463
611
  else
@@ -469,6 +617,39 @@ function SameValue(a, b) {
469
617
  return a === b || (!!a && !!b && a.Now === b.Now && a.Min === b.Min && a.Max === b.Max && a.Step === b.Step && a.Text === b.Text);
470
618
  }
471
619
  // ---- group helpers (duck-typed layouts and scrolls) ----
620
+ function IsInside(control, root) {
621
+ for (let c = control; c; c = c.Parent)
622
+ if (c === root)
623
+ return true;
624
+ return false;
625
+ }
626
+ /** The top of the tree a control is in: the canvas content, or a popup window's root. */
627
+ function TopRoot(control) {
628
+ let c = control;
629
+ while (c.Parent)
630
+ c = c.Parent;
631
+ return c;
632
+ }
633
+ /** Drawing order: `a` draws over `b` (ZIndex, then tree order; a nested control over its ancestor). */
634
+ function IsDrawnAbove(a, b) {
635
+ const path = (c) => { const p = []; for (let x = c; x; x = x.Parent)
636
+ p.unshift(x); return p; };
637
+ const pa = path(a), pb = path(b);
638
+ let i = 0;
639
+ while (i < pa.length && i < pb.length && pa[i] === pb[i])
640
+ i++;
641
+ if (i === pa.length)
642
+ return false; // a contains b
643
+ if (i === pb.length)
644
+ return true; // b contains a
645
+ if (i === 0)
646
+ return false; // different trees (a popup window): the first one found stays
647
+ const sa = pa[i], sb = pb[i];
648
+ if (sa.ZIndex !== sb.ZIndex)
649
+ return sa.ZIndex > sb.ZIndex;
650
+ const views = ViewsOf(sa.Parent);
651
+ return views.indexOf(sa) > views.indexOf(sb);
652
+ }
472
653
  /** A node the keyboard can land on: a role that is not presentation and takes input. */
473
654
  function IsInteractiveNode(c) {
474
655
  return !!c.AccessibilityRole && c.AccessibilityRole !== Aria.RolePresentation && c.IsAccessibilityElement && c.AccessibilityCanInteract;
@@ -1,5 +1,5 @@
1
1
  import type { Surface } from "canvaskit-wasm";
2
- import type { DrawingContext, SkiaControl } from "./SkiaControl";
2
+ import { type DrawingContext, type SkiaControl } from "./SkiaControl";
3
3
  import type { AnimatorBase } from "./Animators";
4
4
  import { SkiaAccessibilityManager } from "./Accessibility";
5
5
  import { HoverManager } from "./Hover";
@@ -61,6 +61,15 @@ export declare class Canvas {
61
61
  private popupKeysHooked;
62
62
  /** Raised when a popup window closed: picked, a press outside, Escape, the wheel, window blur or ClosePopupWindow. */
63
63
  readonly PopupWindowClosed: Set<(id: PopupId) => void>;
64
+ /** The root controls of the open popup windows, bottom to top: a read-only view for tools (a new array per read). */
65
+ get PopupWindowRoots(): readonly SkiaControl[];
66
+ private wasDrawnListeners?;
67
+ /**
68
+ * Handlers run at the end of every drawn frame, after the `WasDrawn` callback and before the surface is flushed (a
69
+ * tool drawing an overlay on `Surface.getCanvas()`). Made on first use: a canvas without listeners does no work.
70
+ */
71
+ get WasDrawnListeners(): Set<(sender: Canvas) => void>;
72
+ private readonly raiseWasDrawn;
64
73
  /**
65
74
  * Shows `content` over everything, opening from `anchor` the way native menus do: at a point (a right click, canvas
66
75
  * points), or below a rect or a control (a dropdown), flipped to the other side where it does not fit. It closes with
@@ -76,6 +85,19 @@ export declare class Canvas {
76
85
  ClosePopupWindows(): void;
77
86
  /** The popup window is still open. */
78
87
  IsPopupWindowOpen(id: PopupId): boolean;
88
+ /**
89
+ * Moves the keyboard and screen-reader focus to `control` at the end of the next frame, for app code such as a custom
90
+ * menu that moves its highlight (C# DrawnView.SetAccessibilityFocus). A control not drawn yet gets it once it is, within
91
+ * 3 seconds. It wins over the library's own moves in the same frame (a closed popup window giving the keyboard back to
92
+ * its opener); undefined cancels a move still waiting. The focus ring shows only if the keyboard is in use.
93
+ */
94
+ SetAccessibilityFocus(control?: SkiaControl): void;
95
+ /**
96
+ * The drawn control with the keyboard and screen-reader focus (C# KeyboardFocusNode). Set undefined to let no drawn
97
+ * control keep it: the DOM focus goes back to the canvas and the keys belong to the app; a control moves it there.
98
+ */
99
+ get KeyboardFocusNode(): SkiaControl | undefined;
100
+ set KeyboardFocusNode(control: SkiaControl | undefined);
79
101
  /** True while a popup window that takes input is open. */
80
102
  get HasPopupWindows(): boolean;
81
103
  /** The content of the top popup window that takes input. */
@@ -85,7 +107,6 @@ export declare class Canvas {
85
107
  RaisePopupWindowClosed(id: PopupId): void;
86
108
  private AfterPopupsChanged;
87
109
  private readonly onPopupKey;
88
- private readonly onPopupChar;
89
110
  private HookPopupKeys;
90
111
  private readonly onWindowBlur;
91
112
  private content?;
@@ -142,6 +163,13 @@ export declare class Canvas {
142
163
  readonly AnimatingControls: Map<number, AnimatorBase>;
143
164
  RegisterAnimator(animator: AnimatorBase): boolean;
144
165
  UnregisterAnimator(uid: number): void;
166
+ /**
167
+ * `root` leaves this canvas (removed from its parent, replaced as content, disposed): what runs for its subtree stops,
168
+ * as DrawnUi.Rust 44c718f. Its animators leave the frame loop: disposed, they stop; only removed, they pause and wait on
169
+ * their control (PendingUnattachedAnimators), going on from there when it is arranged on a canvas again. A focused editor in it loses the
170
+ * focus, a game in it stops getting keys (CanvasLeaveWatchers). Runs once per removal, never per frame.
171
+ */
172
+ ControlLeft(root: SkiaControl, disposed: boolean): void;
145
173
  /** Ticks every registered animator once; returns how many ran. */
146
174
  protected ExecuteAnimators(frameTimeNanos: number): number;
147
175
  private wakeTimer;
@@ -237,6 +265,10 @@ export declare class Canvas {
237
265
  private DetachInput;
238
266
  /** Port of DrawnUi.Blazor Canvas.OnTouchAction: per-pointer state machine producing Down / Panning / Tapped / Up. */
239
267
  OnTouchAction(args: TouchActionEventArgs): void;
268
+ /** The fingers down, for TouchActionEventArgs.Manipulation (pinch and turn). */
269
+ private readonly fingers;
270
+ /** The press had a second finger: it is no tap (AppoMobi.Blazor.Gestures). */
271
+ private multiTouch;
240
272
  private readonly longPressTimers;
241
273
  private readonly longPressed;
242
274
  /** The long press of a new press: due LongPressTimeMs later unless the pointer moves away or lets go. */
@@ -253,10 +285,25 @@ export declare class Canvas {
253
285
  private gestureOwner;
254
286
  /** DrawnUi IsSavedGesture: the types replayed to the owner instead of being routed again. */
255
287
  private static IsSavedGesture;
288
+ private arrowsStart;
289
+ /**
290
+ * While no drawn control has keyboard focus (or only one behind the active modal), the arrow keys start keyboard
291
+ * navigation as the first Tab does: Down and Right go to the first Tab stop, Up and Left to the last, and the key is used
292
+ * for that. Once a control has focus the arrows work as usual (inside a list or a menu). Off by default, since games use
293
+ * the arrows as their own keys while nothing is focused: an app turns it on for its menu screens and off while playing.
294
+ */
295
+ get ArrowsStartKeyboardNavigation(): boolean;
296
+ set ArrowsStartKeyboardNavigation(v: boolean);
297
+ private readonly onArrowKey;
256
298
  private focusedChild?;
257
299
  private focusAtDown?;
258
300
  private tapNoFocus;
259
301
  private reportingFocus;
302
+ /**
303
+ * A control that left the canvas (removed or disposed) is let go by the focus, the gesture dispatch and the tooltips,
304
+ * so the last control that took input does not keep its page alive (C# 4cb28ab6). Checked once per frame.
305
+ */
306
+ private ForgetGoneControls;
260
307
  /** The control that has the canvas focus (an editor while it edits, a CanBeFocused control that was tapped). */
261
308
  get FocusedChild(): SkiaControl | undefined;
262
309
  /**