So I have the following code in my editor plugin script:
@tool
extends EditorPlugin
func _enter_tree():
main_screen_changed.connect(screen_changed)
func _input(event):
#mouse click
if event is InputEventMouseButton:
if event.button_index == MOUSE_BUTTON_LEFT and event.is_pressed():
print( "mouse clicked -> " + str(EditorInterface.get_editor_main_screen( )) )
var object = EditorInterface.get_edited_scene_root().find_child('object', false, false)
object.position = object.position + vector3(0,10,0)
func screen_changed(screen):
print(screen)
here is my issue: when I click on the inspector dock or the scene dock or the “scripts” section of the main dock I get this message registering my click:
"mouse clicked → MainScreen:<VBoxContainer#81252059715> "
but I do not want to register a click on inspector or anywhere other than the 3D view, since I am modifying objects that are clicked on. (in this example I move object up 10 on y-axis). How can I limit the registering of inputs ONLY in the main screen and only if we are looking at the 3D viewport.
TO NOTE:
interestingly, adding screen_changed function as I did DOES register when I switch the view from 2D, 3D, Script, AssetLib
which is weird because EditorInterface.get_editor_main_screen( ) gets just the main panel, whereas main_screen_changed.connect(screen_changed) gets the main panel’s current view (which is what I want!)
how do I do this? how do I get if we clicked in the MAIN SCREEN and only if we are n 3D VIEW???
**note: checking if the click was on the object or in the viewport bounds is not a viable solution, because the other panels can go OVER the viewport and still register the click.