This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes
var dict1 = {}
func _input(_event):
    dict_grab_focus.clear()
    if Input.is_key_pressed(KEY_TAB):
        get_node("Button").grab_focus()

    if Input.is_key_pressed(KEY_TAB) or Input.is_key_pressed(KEY_F):

        for i in get_children():

            dict_grab_focus[i] = i.has_focus()

#       print("dic", dict_grab_focus.values())
#       if 3 == 3:
#           print(dict_grab_focus.values(), "grab focus has true")

        if dict_grab_focus.values():
            print("dic", dict_grab_focus.values())
            print(dict_grab_focus.values(), "grab focus has true")
            get_node("Button").grab_focus()

I can't reach my values of dictunary, I want to see if any of the keys() has a values() with true, so I wont run the function of assigning grab_focus()

in Engine by (193 points)

1 Answer

0 votes

Found it right after posting the q/a:

var dict1 = {}
func _input(_event):
    dict_grab_focus.clear()
    if Input.is_key_pressed(KEY_TAB):
        get_node("Button").grab_focus()

    if Input.is_key_pressed(KEY_TAB) or Input.is_key_pressed(KEY_F):

        for i in get_children():

            dict_grab_focus[i] = String(i.has_focus()) # Was saving like this to dictionary i.has_focus() thus, if, the dictionary doesn't know it is saved as a dictionary, it can't find it

#       print("dic", dict_grab_focus.values())
#       if 3 == 3:
#           print(dict_grab_focus.values(), "grab focus has true")

        if not dict_grab_focus.values().has("True"):
            print("dic", dict_grab_focus.values())
            print(dict_grab_focus.values(), "grab focus has false, now true")
            get_node("Button").grab_focus()

        if dict_grab_focus.values().has("True"):
            print("dic", dict_grab_focus.values())
            print(dict_grab_focus.values(), "grab focus has true already")
by (193 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.