0 votes

im trying to bind to the "selection changed" event inside an editor plugin:

func _enter_tree():
    dock = preload("res://xxx.tscn").instance()
    dock.set_name("somename");
    add_control_to_dock( DOCK_SLOT_RIGHT_BL, dock)

    var s
    s = get_selection() // seems to work (no error msg)
    var arr = s.get_selected_nodes()  //seems to work (no error msg)
    connect("selection_changed",s,"selected_changed1") //error: described below

func selected_changed1():
...

the error i get when trying to connect to the event is:

ERROR: In Object of type "EditorPlugin": Attempt to connect nonexistent signal  "selection_changed" to method "EditorSelection.selected_changed1"

but in editor_data.cpp i find:

void EditorSelection::_bind_methods() {
     .....
ADD_SIGNAL(MethodInfo("selection_changed")); 
    .....

}

in Engine by (63 points)
edited by

1 Answer

+2 votes
Best answer

This is how I do it in 2.1.2:

get_selection().connect("selection_changed", self, "_on_selection_changed")
by (486 points)
selected by

This is correct. The reason is because "selection_changed" is a signal on the class EditorSelection.

http://docs.godotengine.org/en/stable/classes/class_editorselection.html#class-editorselection

You get one with a call to 'get_selection()' inside the EditorPlugin.

tnx for the really fast answer :)

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.