mirror of
https://github.com/anomalyco/hex.git
synced 2026-11-28 13:02:21 +01:00
A tester asked to hold to talk instead of tapping Dictate and then Done. Rule: holding still for 0.35 s (HexKeyGesture.holdDuration, the Hex key's existing hold) starts dictation at once, and lifting the finger finishes it as Done does. A quick tap keeps tap to start, Done to finish. On the Hex key, sliding more than 10 pt before the hold fires still opens the style menu; once dictation has started, moving changes nothing. Push to talk applies only when dictation runs in the keyboard (warm session or in-keyboard dictation); a hold that opens Hex stays a tap. - HexKeyGesture: a fired hold's touch-up is now .release (was ignored). Changed: before, a hold started dictation and the release did nothing. - HexKeyControl calls onHoldRelease; FullKeyboardView finishes the dictation the hold started (model.onStopTap, logged as dictation_stop from hex_key_release). The recording fade keeps a still-tracking Hex key in the window at alpha 0 instead of hiding it, so its touch keeps arriving. - KeyboardSurfaceView: the well tracks the press with a simultaneous DragGesture on the same state machine (the Dictate button stops taking touches once recording shows), starts with the light haptic (onKeyFeedback: Haptics setting and Full Access), and finishes on release; the button's own touch-up action skips a press the hold took. - Accessibility hints mention holding; README and docs/typing-logs.md describe it. Verified: xcodebuild test on the iPhone 18 Pro simulator, 213 tests pass (1 skipped as before), including the updated HexKeyGesture tests (hold then release finishes; moving after the hold is ignored). The dictation bar renders as before (--snap-state keyboard-warm). Real touches (hold timing, the bar's buttons with the well's gesture, the Hex key's touch surviving the recording panel) were not driven on the simulator and need a physical iPhone.
50 lines
2 KiB
Swift
50 lines
2 KiB
Swift
import CoreGraphics
|
|
import XCTest
|
|
@testable import HEX
|
|
|
|
final class HexKeyGestureTests: XCTestCase {
|
|
func testTapDictates() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 3, y: 2)), .ignored, "a jitter is still a tap")
|
|
XCTAssertEqual(gesture.touchUp(), .tap)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored, "a timer left over from the tap")
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
}
|
|
|
|
func testStillHoldFiresOnceAndReleaseFinishes() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.holdElapsed(), .hold)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored)
|
|
XCTAssertEqual(gesture.touchUp(), .release, "push to talk: lifting finishes")
|
|
XCTAssertEqual(gesture.touchUp(), .ignored)
|
|
}
|
|
|
|
func testMoveBeforeHoldOpensMenu() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: CGPoint(x: 20, y: 20))
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 20, y: 9)), .openMenu)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored, "the menu won, no dictation")
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 0, y: -40)), .dragMenu)
|
|
XCTAssertEqual(gesture.touchUp(), .releaseMenu)
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
}
|
|
|
|
func testMoveAfterHoldDoesNothing() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
XCTAssertEqual(gesture.holdElapsed(), .hold)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 0, y: -80)), .ignored, "no menu once dictating")
|
|
XCTAssertEqual(gesture.touchUp(), .release)
|
|
}
|
|
|
|
func testCancelResets() {
|
|
var gesture = HexKeyGesture()
|
|
gesture.touchDown(at: .zero)
|
|
gesture.cancel()
|
|
XCTAssertEqual(gesture.state, .idle)
|
|
XCTAssertEqual(gesture.holdElapsed(), .ignored)
|
|
XCTAssertEqual(gesture.touchMoved(to: CGPoint(x: 50, y: 0)), .ignored)
|
|
}
|
|
}
|