+1 vote

I have found something that maybe a bug or just a lack of experience on my part. I have simplified at maximum the problem.

I have the following scene:

Node2D
    |--> PopupMenu

In the root node (Node2D) I have the following code:

extends Node2D

func _input(event):
    if event is InputEventMouseButton:
        if event.pressed:
            Input.set_default_cursor_shape(Input.CURSOR_DRAG)
            pass
        else:
            Input.set_default_cursor_shape(Input.CURSOR_ARROW)

In the second node (PopupMenu) I have this code:

extends PopupMenu

func _ready():
    add_item("item a")
    add_item("item b")
    add_item("item c")

    connect("id_pressed", self, "_on_item_pressed")
    popup()

func _on_item_pressed(id):
    print(get_item_text(id), " pressed")

Nothing else. No more config in a standard Godot 3.1 project.

Now, if I run the project, I see the popup menu in screen, but if I click to any of the items nothing happens (print is never executed).

In order to get print running I have to comment or remove the line Input.set_default_cursor_shape(Input.CURSOR_DRAG) in "Node2D.gd" and then the result is the expected with the print showing the option selected.

Why is this happening?

(Of course, this program has no sense, that's just a simplification of my real program).

in Engine by (36 points)

I'm a little confused about your code but I do know this you do not need pass in that code. Pass is mostly for debugging, what pass does is it tells the computer that if there is a error in the place to simply keep going along the code and ignore it.

Yes @merlin1846, I have left the pass just to put a comment at the previous line for debugging purposes (the code itself is just a minimum test with the problem I observed, my real code is much more complex)

Please log in or register to answer this question.

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 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 webmaster@godotengine.org with your username.