diff --git a/test/demo/main.gd b/test/demo/main.gd index 7c141cf..302e1be 100644 --- a/test/demo/main.gd +++ b/test/demo/main.gd @@ -96,6 +96,13 @@ func _ready(): assert_equal($Example.test_bitfield(0), 0) assert_equal($Example.test_bitfield(Example.FLAG_ONE | Example.FLAG_TWO), 3) + # Virtual method. + var event = InputEventKey.new() + event.key_label = KEY_H + event.unicode = 72 + get_viewport().push_input(event) + assert_equal(custom_signal_emitted, ["_input: H", 72]) + exit_with_status() func _on_Example_custom_signal(signal_name, value): diff --git a/test/src/example.cpp b/test/src/example.cpp index 6d24379..93d00f5 100644 --- a/test/src/example.cpp +++ b/test/src/example.cpp @@ -348,3 +348,10 @@ bool Example::_has_point(const Vector2 &point) const { return false; } + +void Example::_input(const Ref &event) { + const InputEventKey* key_event = Object::cast_to(*event); + if (key_event) { + emit_custom_signal("_input: " + key_event->get_key_label(), key_event->get_unicode()); + } +} diff --git a/test/src/example.h b/test/src/example.h index ebf9156..8c8b250 100644 --- a/test/src/example.h +++ b/test/src/example.h @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -129,6 +130,7 @@ public: // Virtual function override (no need to bind manually). virtual bool _has_point(const Vector2 &point) const override; + virtual void _input(const Ref &event) override; }; VARIANT_ENUM_CAST(Example::Constants);