adding focus handling to card board
This commit is contained in:
parent
079150aa10
commit
67cde4ca17
|
|
@ -3,6 +3,16 @@ extends PanelContainer
|
|||
var area_dict = {}
|
||||
enum ui_context {DROPZONE, POST_IT_LIST, ASSIGN_POST_IT}
|
||||
|
||||
var has_focus = false:
|
||||
set(focus):
|
||||
if focus != has_focus:
|
||||
if focus:
|
||||
has_focus = true
|
||||
self.mouse_filter = Control.MOUSE_FILTER_PASS
|
||||
else:
|
||||
has_focus = false
|
||||
self.mouse_filter = Control.MOUSE_FILTER_IGNORE
|
||||
|
||||
@onready var dropzone = $HBoxContainer/dropzone
|
||||
@onready var postit_container = $HBoxContainer/ScrollContainer/VBoxContainer
|
||||
@onready var board_of_devs = $"board of devs"
|
||||
|
|
@ -31,13 +41,12 @@ func _ready():
|
|||
func _process(delta):
|
||||
# Reset information about Areas being dragged, if the mouse is not longer pressed.
|
||||
# Needed because otherwise it can happen that the areas don't register it if you stop clicking on them.
|
||||
if !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and is_area_dragged:
|
||||
if has_focus and !Input.is_mouse_button_pressed(MOUSE_BUTTON_LEFT) and is_area_dragged:
|
||||
currently_dragged_area.is_dragged = false
|
||||
is_area_dragged = false
|
||||
currently_dragged_area = null
|
||||
|
||||
|
||||
|
||||
# Will be used later to spawn Cards and Post-Its and remember them in the dictionary
|
||||
func populate_board(card_names: Array):
|
||||
var all_cards = Array()
|
||||
|
|
@ -191,7 +200,7 @@ func reorder_areas(reorder: String):
|
|||
# Takes the inputs for control inputs
|
||||
func _input(event):
|
||||
# Return, if the input is a mouse event (mouse events are handled separately)
|
||||
if event is InputEventMouse: return
|
||||
if event is InputEventMouse or !has_focus: return
|
||||
|
||||
if event.is_action_pressed("ui_up"): # up to select an element above
|
||||
match active_context:
|
||||
|
|
|
|||
Loading…
Reference in New Issue