mirror of
https://github.com/thegatesbrowser/thegates.git
synced 2025-08-24 11:17:26 -04:00
help button, scroll with prompt
This commit is contained in:
parent
00fa349440
commit
647b0ca20c
6 changed files with 142 additions and 15 deletions
17
app/scripts/ui/menu/scroll_container.gd
Normal file
17
app/scripts/ui/menu/scroll_container.gd
Normal file
|
@ -0,0 +1,17 @@
|
|||
extends ScrollContainer
|
||||
|
||||
@export var search: Search
|
||||
@export var scroll_speed: float
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not search.has_focus(): return
|
||||
if event is not InputEventMouseButton: return
|
||||
if not get_global_rect().has_point(event.position): return
|
||||
if not search.prompt_panel.get_global_rect().has_point(event.position): return
|
||||
|
||||
if event.button_index == MouseButton.MOUSE_BUTTON_WHEEL_UP:
|
||||
scroll_vertical -= scroll_speed * event.factor
|
||||
|
||||
if event.button_index == MouseButton.MOUSE_BUTTON_WHEEL_DOWN:
|
||||
scroll_vertical += scroll_speed * event.factor
|
|
@ -44,7 +44,8 @@ func _input(event: InputEvent) -> void:
|
|||
|
||||
if (event is InputEventMouseButton
|
||||
and not get_global_rect().has_point(event.position)
|
||||
and not prompt_panel.get_global_rect().has_point(event.position)):
|
||||
and not prompt_panel.get_global_rect().has_point(event.position)
|
||||
and not event.button_index in [MOUSE_BUTTON_WHEEL_UP, MOUSE_BUTTON_WHEEL_DOWN]):
|
||||
release_focus()
|
||||
on_release_focus.emit()
|
||||
|
||||
|
|
|
@ -1,13 +1,30 @@
|
|||
extends Control
|
||||
|
||||
@export var search_le: LineEdit
|
||||
@export var search: Search
|
||||
|
||||
var update_position: bool
|
||||
|
||||
|
||||
func _ready() -> void:
|
||||
search_le.resized.connect(change_size)
|
||||
search_le.focus_entered.connect(change_size)
|
||||
search.resized.connect(change_size)
|
||||
search.focus_entered.connect(change_size)
|
||||
|
||||
|
||||
func change_size() -> void:
|
||||
global_position = get_parent().global_position
|
||||
size.x = search_le.size.x
|
||||
size.x = search.size.x
|
||||
|
||||
|
||||
func _input(event: InputEvent) -> void:
|
||||
if not search.has_focus(): return
|
||||
|
||||
if (event is InputEventMouseButton
|
||||
and event.button_index in [MOUSE_BUTTON_WHEEL_UP, MOUSE_BUTTON_WHEEL_DOWN]):
|
||||
update_position = true
|
||||
|
||||
|
||||
func _process(_delta: float) -> void:
|
||||
if not update_position: return
|
||||
|
||||
global_position = get_parent().global_position
|
||||
update_position = false
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue