fix(input): let swipes reach scroll containers
Godot ScrollContainer only receives drag gestures when the controls under the finger pass them through. Guest Book cards, House Rules rows, and Settings rows now use PASS, so swiping scrolls while taps, toggles, sliders, and buttons still work. The tutorial board keeps its own input.
This commit is contained in:
1 parent
dffdee63a6
commit
d679a12e1d
5 files changed
+47
-4
No files matched your search
@@ -134,6 +134,10 @@ func refresh() -> void:
|
|||||||
for guest in guests:
|
for guest in guests:
|
||||||
grid.add_child(_make_card(guest))
|
grid.add_child(_make_card(guest))
|
||||||
|
|
||||||
|
# Let a finger drag reach the ScrollContainer even when it starts on a
|
||||||
|
# card; the card still gets its own press/release for tap detection.
|
||||||
|
UI.pass_scroll_input(grid)
|
||||||
|
|
||||||
|
|
||||||
func _make_card(guest: Dictionary) -> PanelContainer:
|
func _make_card(guest: Dictionary) -> PanelContainer:
|
||||||
var id := str(guest["id"])
|
var id := str(guest["id"])
|
||||||
@@ -241,9 +245,9 @@ func _on_card_input(event: InputEvent, guest: Dictionary, locked: bool) -> void:
|
|||||||
if scrolled:
|
if scrolled:
|
||||||
_suppress_until = now + DRAG_SUPPRESS_MS
|
_suppress_until = now + DRAG_SUPPRESS_MS
|
||||||
|
|
||||||
# Consume the release either way: a scroll must not fall through to a
|
# Do not consume the event: the ScrollContainer needs the release to end
|
||||||
# card, and a tap must not reach the detail sheet that is about to open.
|
# its drag. A real tap is still safe because the detail sheet guards
|
||||||
accept_event()
|
# Close for 250ms after opening.
|
||||||
if not is_tap:
|
if not is_tap:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,11 @@ func _ready() -> void:
|
|||||||
if not tutorial.is_empty():
|
if not tutorial.is_empty():
|
||||||
tutorial_board.set_level(tutorial)
|
tutorial_board.set_level(tutorial)
|
||||||
|
|
||||||
|
# Everything in the rules list passes drags to the ScrollContainer, so
|
||||||
|
# a swipe works over labels and buttons. The practice board keeps its
|
||||||
|
# own input.
|
||||||
|
UI.pass_scroll_input(content, [tutorial_board])
|
||||||
|
|
||||||
|
|
||||||
func _body(text: String) -> Label:
|
func _body(text: String) -> Label:
|
||||||
var label := UI.label(text, 12, Palette.MUTED)
|
var label := UI.label(text, 12, Palette.MUTED)
|
||||||
|
|||||||
@@ -100,6 +100,10 @@ func _ready() -> void:
|
|||||||
reset_status = UI.label("", 10, Palette.MUTED)
|
reset_status = UI.label("", 10, Palette.MUTED)
|
||||||
list.add_child(reset_status)
|
list.add_child(reset_status)
|
||||||
|
|
||||||
|
# Let swipes reach the sheet's ScrollContainer even when they start on a
|
||||||
|
# label, toggle, or button.
|
||||||
|
UI.pass_scroll_input(list)
|
||||||
|
|
||||||
game_actions = HBoxContainer.new()
|
game_actions = HBoxContainer.new()
|
||||||
game_actions.add_theme_constant_override("separation", 6)
|
game_actions.add_theme_constant_override("separation", 6)
|
||||||
column.add_child(game_actions)
|
column.add_child(game_actions)
|
||||||
@@ -283,7 +287,7 @@ func _update_hold_availability() -> void:
|
|||||||
return
|
return
|
||||||
var enabled := not bool(SaveGame.get_setting("double_tap_place"))
|
var enabled := not bool(SaveGame.get_setting("double_tap_place"))
|
||||||
hold_slider.editable = enabled
|
hold_slider.editable = enabled
|
||||||
hold_slider.mouse_filter = Control.MOUSE_FILTER_STOP if enabled else Control.MOUSE_FILTER_IGNORE
|
hold_slider.mouse_filter = Control.MOUSE_FILTER_PASS if enabled else Control.MOUSE_FILTER_IGNORE
|
||||||
hold_panel.modulate = Color(1, 1, 1, 1.0 if enabled else 0.45)
|
hold_panel.modulate = Color(1, 1, 1, 1.0 if enabled else 0.45)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -142,6 +142,19 @@ static func safe_bottom() -> int:
|
|||||||
return 24 if OS.has_feature("mobile") else 14
|
return 24 if OS.has_feature("mobile") else 14
|
||||||
|
|
||||||
|
|
||||||
|
## Godot's ScrollContainer only sees a touch drag when the controls under the
|
||||||
|
## finger let the event through. PASS keeps buttons clickable while allowing
|
||||||
|
## the parent ScrollContainer to handle the same gesture. `skip` protects
|
||||||
|
## controls that must own their input, such as the tutorial Board.
|
||||||
|
static func pass_scroll_input(root: Node, skip: Array = []) -> void:
|
||||||
|
if root is Control and not skip.has(root):
|
||||||
|
root.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||||
|
for child in root.get_children():
|
||||||
|
if skip.has(child):
|
||||||
|
continue
|
||||||
|
pass_scroll_input(child, skip)
|
||||||
|
|
||||||
|
|
||||||
## Short control hint that follows the saved placement mode.
|
## Short control hint that follows the saved placement mode.
|
||||||
static func place_hint() -> String:
|
static func place_hint() -> String:
|
||||||
if bool(SaveGame.get_setting("double_tap_place")):
|
if bool(SaveGame.get_setting("double_tap_place")):
|
||||||
|
|||||||
@@ -55,6 +55,14 @@ func _run() -> void:
|
|||||||
|
|
||||||
_test_placement_modes(save, main.game.board)
|
_test_placement_modes(save, main.game.board)
|
||||||
|
|
||||||
|
main.open_settings("home")
|
||||||
|
await process_frame
|
||||||
|
_check(
|
||||||
|
main.settings_sheet.toggles["double_tap_place"].mouse_filter == Control.MOUSE_FILTER_PASS,
|
||||||
|
"settings rows should pass swipes to the ScrollContainer"
|
||||||
|
)
|
||||||
|
main.close_settings()
|
||||||
|
|
||||||
var unlocked: String = save.complete_room("room-01", 1)
|
var unlocked: String = save.complete_room("room-01", 1)
|
||||||
_check(unlocked == "pepper", "room 1 should unlock Pepper")
|
_check(unlocked == "pepper", "room 1 should unlock Pepper")
|
||||||
_check(save.is_guest_unlocked("pepper"), "Pepper should be unlocked")
|
_check(save.is_guest_unlocked("pepper"), "Pepper should be unlocked")
|
||||||
@@ -67,12 +75,21 @@ func _run() -> void:
|
|||||||
if main.guest_book != null and main.guest_book.progress_label != null:
|
if main.guest_book != null and main.guest_book.progress_label != null:
|
||||||
_check(main.guest_book.progress_label.text.find("6/25") >= 0, "Guest Book progress should be 6/25")
|
_check(main.guest_book.progress_label.text.find("6/25") >= 0, "Guest Book progress should be 6/25")
|
||||||
_test_guest_book_input(main.guest_book)
|
_test_guest_book_input(main.guest_book)
|
||||||
|
_check(main.guest_book.grid.mouse_filter == Control.MOUSE_FILTER_PASS, "guest grid should pass swipes")
|
||||||
|
var first_card = main.guest_book.grid.get_child(0)
|
||||||
|
_check(first_card.mouse_filter == Control.MOUSE_FILTER_PASS, "guest cards should pass swipes")
|
||||||
|
|
||||||
main.show_screen("rules")
|
main.show_screen("rules")
|
||||||
await process_frame
|
await process_frame
|
||||||
var tutorial_board = main.rulebook.tutorial_board
|
var tutorial_board = main.rulebook.tutorial_board
|
||||||
_check(tutorial_board != null, "Tutorial board missing")
|
_check(tutorial_board != null, "Tutorial board missing")
|
||||||
if tutorial_board != null:
|
if tutorial_board != null:
|
||||||
|
var rule_scrolls = main.rulebook.find_children("*", "ScrollContainer", true, false)
|
||||||
|
_check(rule_scrolls.size() > 0, "Rules ScrollContainer missing")
|
||||||
|
if rule_scrolls.size() > 0:
|
||||||
|
var rules_content = rule_scrolls[0].get_child(0)
|
||||||
|
_check(rules_content.mouse_filter == Control.MOUSE_FILTER_PASS, "rules content should pass swipes")
|
||||||
|
_check(tutorial_board.mouse_filter == Control.MOUSE_FILTER_STOP, "tutorial board should keep its own input")
|
||||||
for i in range(8):
|
for i in range(8):
|
||||||
tutorial_board.hint()
|
tutorial_board.hint()
|
||||||
await process_frame
|
await process_frame
|
||||||
|
|||||||
Reference in new issue
Block a user