Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/components/v_box_list/item/h_box_list_item.gd
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ signal double_clicked
signal hover_changed(is_hovering: bool)
signal selected_changed(is_selected: bool)

var _double_click_cooldown := 0.0
const DOUBLE_CLICK_COOLDOWN_TIME := 200


var _is_hovering := false:
set(value):
Expand Down Expand Up @@ -34,11 +37,14 @@ func _input(event: InputEvent) -> void:


func _gui_input(event: InputEvent) -> void:
var time := Time.get_ticks_msec()
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this declaration line be moved down to just before time is used? (Just before line 44)

That would prevent the variable from being assigned on each GUI Input event if it isn't needed.

var mb := event as InputEventMouseButton
if mb:
if mb.button_index == MOUSE_BUTTON_LEFT:
if mb.double_click:
if mb.double_click and _double_click_cooldown <= time:
double_clicked.emit()
_double_click_cooldown = time + DOUBLE_CLICK_COOLDOWN_TIME

elif mb.is_pressed():
clicked.emit()
if mb.button_index == MOUSE_BUTTON_RIGHT:
Expand Down