| ... | ... | @@ -21,7 +21,8 @@ extension CanvasView { |
| 21 | 21 | /// screenshot command; `snap:a` only logs, for a simulator screenshot with the keyboard; |
| 22 | 22 | /// `activate:Label` activates the element of any window so named, as VoiceOver would, |
| 23 | 23 | /// opening a button's menu or picking a menu's item or a list's row (`Row/Button` for a |
| 24 | | /// button in a row), and `audit` logs whether the format bar and tag grid name every button. |
| 24 | /// button in a row), `back` goes back, and `audit` logs whether the format bar and tag grid |
| 25 | /// name every button. |
| 25 | 26 | func runScript() { |
| 26 | 27 | // Only the first page shown runs it, not every page opened afterwards. |
| 27 | 28 | guard !scriptedPage, let script = ProcessInfo.processInfo.environment["SNOWBOUND_SCRIPT"] else { return } |
| ... | ... | @@ -103,6 +104,13 @@ extension CanvasView { |
| 103 | 104 | let caret = caretRect(for: range.start) |
| 104 | 105 | menu.presentEditMenu(with: UIEditMenuConfiguration(identifier: nil, sourcePoint: CGPoint(x: caret.midX, y: caret.minY))) |
| 105 | 106 | case "done": _ = resignFirstResponder() |
| 107 | case "back": |
| 108 | // The innermost navigation stack shown, as its Back button pops it. |
| 109 | func stacks(_ controller: UIViewController) -> [UINavigationController] { |
| 110 | controller.children.flatMap(stacks) + [controller as? UINavigationController].compactMap { $0 } |
| 111 | } |
| 112 | let shown = Self.windows.compactMap(\.rootViewController).flatMap(stacks) |
| 113 | shown.first { $0.viewControllers.count > 1 && $0.viewIfLoaded?.window != nil }?.popViewController(animated: true) |
| 106 | 114 | case "wait", "snap": break |
| 107 | 115 | case "activate": |
| 108 | 116 | // An alert's button, which takes no accessibility activation outside VoiceOver. |
| ... | ... | @@ -144,6 +152,11 @@ extension CanvasView { |
| 144 | 152 | list.selectItem(at: index, animated: false, scrollPosition: []) |
| 145 | 153 | list.delegate?.collectionView?(list, didSelectItemAt: index) |
| 146 | 154 | } |
| 155 | } else if let cell = found as? UITableViewCell, let table = chain.lazy.compactMap({ $0 as? UITableView }).first, |
| 156 | let index = table.indexPath(for: cell) |
| 157 | { |
| 158 | table.selectRow(at: index, animated: false, scrollPosition: .none) |
| 159 | table.delegate?.tableView?(table, didSelectRowAt: index) |
| 147 | 160 | } else if !found.accessibilityActivate(), let control = found as? UIControl { |
| 148 | 161 | control.sendActions(for: .primaryActionTriggered) |
| 149 | 162 | } |