-fixes to vmethod for button
This commit is contained in:
parent
e361e8539c
commit
8ad12525a9
4 changed files with 33 additions and 2 deletions
|
@ -30,7 +30,7 @@
|
||||||
#include "os/keyboard.h"
|
#include "os/keyboard.h"
|
||||||
#include "print_string.h"
|
#include "print_string.h"
|
||||||
#include "button_group.h"
|
#include "button_group.h"
|
||||||
|
#include "scene/scene_string_names.h"
|
||||||
|
|
||||||
void BaseButton::_input_event(InputEvent p_event) {
|
void BaseButton::_input_event(InputEvent p_event) {
|
||||||
|
|
||||||
|
@ -60,12 +60,21 @@ void BaseButton::_input_event(InputEvent p_event) {
|
||||||
status.pressing_inside=true;
|
status.pressing_inside=true;
|
||||||
|
|
||||||
pressed();
|
pressed();
|
||||||
|
if (get_script_instance()) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
|
||||||
|
}
|
||||||
|
|
||||||
emit_signal("pressed");
|
emit_signal("pressed");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
status.pressed=!status.pressed;
|
status.pressed=!status.pressed;
|
||||||
pressed();
|
pressed();
|
||||||
|
if (get_script_instance()) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
|
||||||
|
}
|
||||||
emit_signal("pressed");
|
emit_signal("pressed");
|
||||||
|
|
||||||
toggled(status.pressed);
|
toggled(status.pressed);
|
||||||
|
@ -99,6 +108,11 @@ void BaseButton::_input_event(InputEvent p_event) {
|
||||||
if (!toggle_mode) { //mouse press attempt
|
if (!toggle_mode) { //mouse press attempt
|
||||||
|
|
||||||
pressed();
|
pressed();
|
||||||
|
if (get_script_instance()) {
|
||||||
|
Variant::CallError ce;
|
||||||
|
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
|
||||||
|
}
|
||||||
|
|
||||||
emit_signal("pressed");
|
emit_signal("pressed");
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
@ -110,6 +124,10 @@ void BaseButton::_input_event(InputEvent p_event) {
|
||||||
|
|
||||||
toggled(status.pressed);
|
toggled(status.pressed);
|
||||||
emit_signal("toggled",status.pressed);
|
emit_signal("toggled",status.pressed);
|
||||||
|
if (get_script_instance()) {
|
||||||
|
get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -177,6 +195,9 @@ void BaseButton::_input_event(InputEvent p_event) {
|
||||||
emit_signal("pressed");
|
emit_signal("pressed");
|
||||||
|
|
||||||
toggled(status.pressed);
|
toggled(status.pressed);
|
||||||
|
if (get_script_instance()) {
|
||||||
|
get_script_instance()->call(SceneStringNames::get_singleton()->_toggled,status.pressed);
|
||||||
|
}
|
||||||
emit_signal("toggled",status.pressed);
|
emit_signal("toggled",status.pressed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -362,6 +383,9 @@ void BaseButton::_bind_methods() {
|
||||||
ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
|
ObjectTypeDB::bind_method(_MD("get_click_on_press"),&BaseButton::get_click_on_press);
|
||||||
ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
|
ObjectTypeDB::bind_method(_MD("get_draw_mode"),&BaseButton::get_draw_mode);
|
||||||
|
|
||||||
|
BIND_VMETHOD(MethodInfo("_pressed"));
|
||||||
|
BIND_VMETHOD(MethodInfo("_toggled",PropertyInfo(Variant::BOOL,"pressed")));
|
||||||
|
|
||||||
ADD_SIGNAL( MethodInfo("pressed" ) );
|
ADD_SIGNAL( MethodInfo("pressed" ) );
|
||||||
ADD_SIGNAL( MethodInfo("released" ) );
|
ADD_SIGNAL( MethodInfo("released" ) );
|
||||||
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
|
ADD_SIGNAL( MethodInfo("toggled", PropertyInfo( Variant::BOOL,"pressed") ) );
|
||||||
|
@ -369,6 +393,7 @@ void BaseButton::_bind_methods() {
|
||||||
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
|
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "toggle_mode"), _SCS("set_toggle_mode"), _SCS("is_toggle_mode"));
|
||||||
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
|
ADD_PROPERTY( PropertyInfo( Variant::BOOL, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
|
||||||
|
|
||||||
|
|
||||||
BIND_CONSTANT( DRAW_NORMAL );
|
BIND_CONSTANT( DRAW_NORMAL );
|
||||||
BIND_CONSTANT( DRAW_PRESSED );
|
BIND_CONSTANT( DRAW_PRESSED );
|
||||||
BIND_CONSTANT( DRAW_HOVER );
|
BIND_CONSTANT( DRAW_HOVER );
|
||||||
|
|
|
@ -147,4 +147,7 @@ SceneStringNames::SceneStringNames() {
|
||||||
_mouse_enter=StaticCString::create("_mouse_enter");
|
_mouse_enter=StaticCString::create("_mouse_enter");
|
||||||
_mouse_exit=StaticCString::create("_mouse_exit");
|
_mouse_exit=StaticCString::create("_mouse_exit");
|
||||||
|
|
||||||
|
_pressed=StaticCString::create("_pressed");
|
||||||
|
_toggled=StaticCString::create("_toggled");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -95,6 +95,9 @@ public:
|
||||||
StringName _input;
|
StringName _input;
|
||||||
StringName _ready;
|
StringName _ready;
|
||||||
|
|
||||||
|
StringName _pressed;
|
||||||
|
StringName _toggled;
|
||||||
|
|
||||||
StringName _update_scroll;
|
StringName _update_scroll;
|
||||||
StringName _update_xform;
|
StringName _update_xform;
|
||||||
|
|
||||||
|
|
|
@ -938,7 +938,7 @@ Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles) {
|
||||||
dst->store_32(0); //pack version
|
dst->store_32(0); //pack version
|
||||||
dst->store_32(VERSION_MAJOR);
|
dst->store_32(VERSION_MAJOR);
|
||||||
dst->store_32(VERSION_MINOR);
|
dst->store_32(VERSION_MINOR);
|
||||||
dst->store_32(VERSION_REVISION);
|
dst->store_32(0); //hmph
|
||||||
for(int i=0;i<16;i++) {
|
for(int i=0;i<16;i++) {
|
||||||
//reserved
|
//reserved
|
||||||
dst->store_32(0);
|
dst->store_32(0);
|
||||||
|
|
Loading…
Reference in a new issue