Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add compatibility properties to TouchScreenButton #78940

Merged
merged 1 commit into from
Jul 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions scene/2d/touch_screen_button.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,19 @@ bool TouchScreenButton::is_passby_press_enabled() const {
return passby_press;
}

#ifndef DISABLE_DEPRECATED
bool TouchScreenButton::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == SNAME("normal")) { // Compatibility with Godot 3.x.
set_texture_normal(p_value);
return true;
} else if (p_name == SNAME("pressed")) { // Compatibility with Godot 3.x.
set_texture_pressed(p_value);
return true;
}
return false;
}
#endif // DISABLE_DEPRECATED

void TouchScreenButton::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture_normal", "texture"), &TouchScreenButton::set_texture_normal);
ClassDB::bind_method(D_METHOD("get_texture_normal"), &TouchScreenButton::get_texture_normal);
Expand Down
3 changes: 3 additions & 0 deletions scene/2d/touch_screen_button.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ class TouchScreenButton : public Node2D {
protected:
void _notification(int p_what);
static void _bind_methods();
#ifndef DISABLE_DEPRECATED
bool _set(const StringName &p_name, const Variant &p_value);
#endif // DISABLE_DEPRECATED

public:
#ifdef TOOLS_ENABLED
Expand Down