0

So I've made this menu for my game in godot. I also made this window which shows up when a button is clicked. This window is WindowDialog in godot, and I want the window to be resizeable. However I get an error when I put the code for the window to be resizeable. Here is my code:

extends WindowDialog

var newSize

func _ready():
    # Change 'hide()' to 'show()' to show the window.
    hide()
    set_process_input(true)
    newSize = self.get_size()
    pass

func _input(event):
    if(event.type == InputEvent.MOUSE_MOTION):
        if(Input.is_mouse_button_pressed(1)):
            if (self.get_local_mouse_position().x > (self.get_size().x - 30)) && (self.get_local_mouse_position().y > (self.get_size().y - 30)) :
                newSize += event.relative_pos
                self.set_size(newSize)
                print(self.get_size().x)
                print(event.relative_x)

The error I get is this:

Invalid get index 'type' (on base: 'InputEventMouseMotion').
RockZombie
  • 101
  • 1
  • 9

1 Answers1

0

To answer the question the title, to make a WindowDialog that can be resized, set its resizable to true.


Now, the error. Do not check a type property, check the type of the event object, like this:

if event is InputEventMouseMotion:
   pass

Or, assuming you want to read the properties of the InputEventMouseMotion, you can do this:

var mouse_motion_event := event as InputEventMouseMotion
if mouse_motion_event != null:
   pass

Something else: You probably don't need to call set_process_input(true), at least not in _ready. If you have an _input function defined, Godot call it (and if it does not have _input, then it won't). Thus, the only reason to call set_process_input(true) is if you called set_process_input(false) before.

Theraot
  • 31,890
  • 5
  • 57
  • 86