Reveal the flashcard answer by tapping the card, not a separate button

Matches the mockup: the "Show Answer" button is replaced by an in-card
"Tap card to reveal answer" hint, and clicking anywhere on the card
reveals it (guarded the same way Space already was - only while at the
live card and not yet revealed).
This commit is contained in:
hz
2026-07-22 17:21:23 -05:00
parent 7f76ca0fdc
commit e8d615985b
3 changed files with 45 additions and 25 deletions
+2 -2
View File
@@ -135,8 +135,8 @@ func _run() -> void:
screen._go_next()
_assert(screen.front_label.text == "P3(live)" and screen.history_cursor == screen.session_history.size(),
"stepping past the last history entry should return to the live card")
_assert(screen.reveal_button.visible and not screen.grade_row.visible,
"returning to a live, unrevealed card should restore the reveal prompt")
_assert(screen.tap_hint_label.visible and not screen.grade_row.visible,
"returning to a live, unrevealed card should restore the tap-to-reveal hint")
screen._go_next()
_assert(screen.session_history.size() == 3 and screen.session_history[2]["action"] == "skipped" and screen.session_history[2]["card_id"] == "card-3",
+19 -2
View File
@@ -29,7 +29,7 @@ func _initialize() -> void:
]
screen._render_card()
_assert(screen.front_label.text == "2 + 2 = ?", "the front should show only the prompt before reveal")
_assert(screen.reveal_button.visible, "the reveal button should be visible before the answer is shown")
_assert(screen.tap_hint_label.visible, "the tap-to-reveal hint should be visible before the answer is shown")
_assert(not screen.grade_row.visible, "grading buttons should be hidden before reveal")
_assert(not screen.back_label.visible, "the back should stay hidden before reveal")
@@ -38,7 +38,7 @@ func _initialize() -> void:
_assert(screen.extra_label.text == "Basic arithmetic" and screen.extra_label.visible, "the extra takeaway should render in its own labeled section")
_assert(screen.answer_caption.visible and screen.extra_caption.visible, "revealing a card with an extra should show both the answer and takeaway captions")
_assert(screen.grade_row.visible, "grading buttons should appear after reveal")
_assert(not screen.reveal_button.visible, "the reveal button should hide once the card is revealed")
_assert(not screen.tap_hint_label.visible, "the tap-to-reveal hint should hide once the card is revealed")
_assert(screen.grade_buttons["good"].text.contains("1d"), "each grade button should show its computed next interval")
# Cloze card: only the card's own variant is hidden on the front; back reveals everything.
@@ -60,6 +60,23 @@ func _initialize() -> void:
screen._reveal()
_assert(not screen.extra_label.visible and not screen.extra_caption.visible, "a card with no extra takeaway should hide that section instead of showing an empty caption")
# Tapping the card panel reveals the answer, same as pressing Space.
screen.current_note = {"type": "basic", "prompt": "Tap test", "answer": "Tapped", "extra": ""}
screen.current_card = {"id": "card-4", "variant": 0, "revision": 1}
screen.revealed = false
screen._render_card()
var click := InputEventMouseButton.new()
click.button_index = MOUSE_BUTTON_LEFT
click.pressed = true
screen._on_card_panel_input(click)
_assert(screen.revealed and screen.back_label.text == "Tapped", "clicking the card panel should reveal the answer")
# A second tap after reveal (or while browsing history) is a no-op - it must not re-trigger
# any reveal side effects (grading is guarded elsewhere; this only checks idempotence).
screen.back_label.text = "Tapped"
screen._on_card_panel_input(click)
_assert(screen.back_label.text == "Tapped", "tapping an already-revealed card should be a no-op")
screen.free()
quit(1 if failures > 0 else 0)