popup() isn't working when being called from within _input()

PopeRigbyPopeRigby Posts: 41Member
in GUI

popup() isn't working on my PopupMenu node when it's an _input function:

func _input(event):
    if event.is_action_pressed("menu"):
        print("pre-popup")
        popup()
        print("post-popup")

These print statements are working, it's just popup() isn't. The weird thing is, popup() works when it's in _process(delta) function, so I don't know what that's about.


Tags :

Best Answer

  • MegalomaniakMegalomaniak Posts: 2,618
    Accepted Answer

    That s because popup needs to be rendered which requires the screen to update which happens in process.

    You could set up a state(boolean var) which gets toggled in _input() that is checked in process and if true then popup() is called in process. Or something like that.

Answers

  • MegalomaniakMegalomaniak Posts: 2,618Admin
    Accepted Answer

    That s because popup needs to be rendered which requires the screen to update which happens in process.

    You could set up a state(boolean var) which gets toggled in _input() that is checked in process and if true then popup() is called in process. Or something like that.

  • PopeRigbyPopeRigby Posts: 41Member

    Thanks! Now I have another problem, but I'll ask that in a different thread.

Leave a Comment

BoldItalicStrikethroughOrdered listUnordered list
Emoji
Image
Align leftAlign centerAlign rightToggle HTML viewToggle full pageToggle lights
Drop image/file