@@ -163,20 +163,18 @@ func release_scope():
163
163
func _input (event ):
164
164
if event is InputEventKey :
165
165
if event .keycode == KEY_SHIFT :
166
- if event .pressed :
167
- _mouse_override .mouse_filter = Control .MOUSE_FILTER_PASS
168
- _mouse_override .mouse_default_cursor_shape = Control .CURSOR_MOVE
169
- else :
170
- _mouse_override .mouse_filter = Control .MOUSE_FILTER_IGNORE
171
- _mouse_override .mouse_default_cursor_shape = Control .CURSOR_ARROW
166
+ set_mouse_override (event .pressed )
172
167
173
168
if event is InputEventMouseButton :
174
- if event .button_index == MOUSE_BUTTON_LEFT :
169
+ if event .button_index == MOUSE_BUTTON_LEFT or event . button_index == MOUSE_BUTTON_MIDDLE :
175
170
if event .pressed and is_mouse_over ():
176
171
_panning = true
177
172
else :
178
173
_panning = false
179
174
175
+ if event .button_index == MOUSE_BUTTON_MIDDLE :
176
+ set_mouse_override (event .pressed )
177
+
180
178
var relative_mouse_pos := get_global_mouse_position () - get_global_rect ().position
181
179
182
180
if is_mouse_over ():
@@ -192,7 +190,7 @@ func _input(event):
192
190
_window .position -= (old_mouse_window_pos - canvas_to_window (relative_mouse_pos )) * _window .scale .x
193
191
194
192
if event is InputEventMouseMotion :
195
- if Input .is_key_pressed (KEY_SHIFT ) and _panning :
193
+ if ( Input .is_key_pressed (KEY_SHIFT ) and _panning ) or ( Input . is_mouse_button_pressed ( MOUSE_BUTTON_MIDDLE ) and _panning ) :
196
194
_window .position += event .relative
197
195
198
196
@@ -206,3 +204,12 @@ func window_to_canvas(v: Vector2) -> Vector2:
206
204
207
205
func is_mouse_over () -> bool :
208
206
return get_global_rect ().has_point (get_global_mouse_position ())
207
+
208
+
209
+ func set_mouse_override (override : bool ):
210
+ if override :
211
+ _mouse_override .mouse_filter = Control .MOUSE_FILTER_PASS
212
+ _mouse_override .mouse_default_cursor_shape = Control .CURSOR_MOVE
213
+ else :
214
+ _mouse_override .mouse_filter = Control .MOUSE_FILTER_IGNORE
215
+ _mouse_override .mouse_default_cursor_shape = Control .CURSOR_ARROW
0 commit comments