-fixes to vmethod for button

This commit is contained in:
Juan Linietsky 2014-12-02 17:26:56 -03:00
parent e361e8539c
commit 8ad12525a9
4 changed files with 33 additions and 2 deletions

View file

@ -30,7 +30,7 @@
#include "os/keyboard.h"
#include "print_string.h"
#include "button_group.h"
#include "scene/scene_string_names.h"
void BaseButton::_input_event(InputEvent p_event) {
@ -60,12 +60,21 @@ void BaseButton::_input_event(InputEvent p_event) {
status.pressing_inside=true;
pressed();
if (get_script_instance()) {
Variant::CallError ce;
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
}
emit_signal("pressed");
} else {
status.pressed=!status.pressed;
pressed();
if (get_script_instance()) {
Variant::CallError ce;
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
}
emit_signal("pressed");
toggled(status.pressed);
@ -99,6 +108,11 @@ void BaseButton::_input_event(InputEvent p_event) {
if (!toggle_mode) { //mouse press attempt
pressed();
if (get_script_instance()) {
Variant::CallError ce;
get_script_instance()->call(SceneStringNames::get_singleton()->_pressed,NULL,0,ce);
}
emit_signal("pressed");
} else {
@ -110,6 +124,10 @@ void BaseButton::_input_event(InputEvent p_event) {
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");
toggled(status.pressed);
if (get_script_instance()) {
get_script_instance()->call(SceneStringNames::get_singleton()->_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_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("released" ) );
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, "click_on_press"), _SCS("set_click_on_press"), _SCS("get_click_on_press"));
BIND_CONSTANT( DRAW_NORMAL );
BIND_CONSTANT( DRAW_PRESSED );
BIND_CONSTANT( DRAW_HOVER );

View file

@ -147,4 +147,7 @@ SceneStringNames::SceneStringNames() {
_mouse_enter=StaticCString::create("_mouse_enter");
_mouse_exit=StaticCString::create("_mouse_exit");
_pressed=StaticCString::create("_pressed");
_toggled=StaticCString::create("_toggled");
}

View file

@ -95,6 +95,9 @@ public:
StringName _input;
StringName _ready;
StringName _pressed;
StringName _toggled;
StringName _update_scroll;
StringName _update_xform;

View file

@ -938,7 +938,7 @@ Error EditorExportPlatform::save_pack(FileAccess *dst,bool p_make_bundles) {
dst->store_32(0); //pack version
dst->store_32(VERSION_MAJOR);
dst->store_32(VERSION_MINOR);
dst->store_32(VERSION_REVISION);
dst->store_32(0); //hmph
for(int i=0;i<16;i++) {
//reserved
dst->store_32(0);