-
Notifications
You must be signed in to change notification settings - Fork 0
/
Node2D.gd
34 lines (30 loc) · 1.15 KB
/
Node2D.gd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
extends Node2D
var all_events = []
var capture = false
func _input(event):
$Label.text = ""
all_events.append(event)
if all_events.size() > 10:
all_events.pop_front()
var text = "";
var e = null;
var i = 0;
while i < all_events.size():
e = all_events[i]
if e is InputEventMouseButton:
text = "clicked {clicked} double {doubleclick} factor {factor} button mask {button_mask} button index {button_index}".\
format({"clicked": e.pressed, "doubleclick": e.doubleclick, "factor": e.factor, "button_mask": e.get_button_mask(), "button_index": e.get_button_index()})
if e is InputEventMouseMotion:
text = "button mask {button_mask}".\
format({"button_mask": e.get_button_mask()})
if e is InputEventKey:
text = "keyboard click {key} {clicked} shift: {shift} alt: {alt} ctrl: {ctrl}".\
format({"clicked": e.pressed, "key": e.keycode, \
"shift": e.shift, "alt": e.alt, "ctrl": e.control})
$Label.text += "\n %s" % text
i += 1
if event is InputEventMouseButton and event.doubleclick and capture:
Input.set_mouse_mode(Input.MOUSE_MODE_VISIBLE)
func _on_Button_pressed():
capture = true
Input.set_mouse_mode(Input.MOUSE_MODE_CAPTURED)