From 67cde4ca17a615ceb10f142ba14f56cc3428415d Mon Sep 17 00:00:00 2001 From: betalars Date: Tue, 11 Jul 2023 15:04:46 +0200 Subject: [PATCH] adding focus handling to card board --- src/logic-scenes/board/card-board.gd | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/logic-scenes/board/card-board.gd b/src/logic-scenes/board/card-board.gd index 6478ab6..9aaf4a9 100644 --- a/src/logic-scenes/board/card-board.gd +++ b/src/logic-scenes/board/card-board.gd @@ -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: