Last active
September 15, 2018 00:27
-
-
Save TheCire/fdb1a36e592591ed4cefcd18685281c7 to your computer and use it in GitHub Desktop.
How should i get mouse dragged to work?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func _input(event): | |
if self.mouse_in_grid && !mouse_has_entered: | |
emit_signal("mouse_entered") | |
if !self.mouse_in_grid && mouse_has_entered: | |
emit_signal("mouse_exited") | |
if should_ignore_mouse || !self.mouse_in_grid: | |
return | |
if event is InputEventMouseButton: | |
var normalizedX = floor(event.position.x / cellSize.x) | |
var normalizedY = floor(event.position.y / cellSize.y) | |
mouse_left_is_pressed = event.pressed && event.button_index == BUTTON_LEFT #set the mouse pressed bool | |
if event.pressed && event.button_index == BUTTON_LEFT: | |
emit_signal("mouse_left_clicked", Vector2(normalizedX, normalizedY)) | |
elif event.pressed && event.button_index == BUTTON_RIGHT: | |
emit_signal("mouse_right_clicked", Vector2(normalizedX, normalizedY), true) | |
elif event is InputEventMouseMotion: | |
if event.position.x >= 0 && event.position.x < (drawSize.x): | |
if event.position.y >= 0 && event.position.y < drawSize.y: | |
var mousePosition = get_local_mouse_position() | |
if mouse_left_is_pressed: | |
print("dragged") | |
emit_signal("mouse_left_dragged", Vector2(normalizedX, normalizedY), false) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment