summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <reduzio@gmail.com>2015-12-12 09:07:43 -0300
committerJuan Linietsky <reduzio@gmail.com>2015-12-12 09:07:43 -0300
commit9a7ff6575179a99dd251154212ddefdd4dc77540 (patch)
tree94bf4245b3b93be6e97a6ede3724c6e9ef924333
parentb191e740d2867c77539e6724aa959e50c78050f9 (diff)
make popup emit index when id is not defined
-rw-r--r--core/variant_call.cpp6
-rw-r--r--scene/gui/popup_menu.cpp17
-rw-r--r--scene/gui/popup_menu.h1
3 files changed, 12 insertions, 12 deletions
diff --git a/core/variant_call.cpp b/core/variant_call.cpp
index 3b04edca1e..2ac876c8f4 100644
--- a/core/variant_call.cpp
+++ b/core/variant_call.cpp
@@ -495,9 +495,6 @@ static void _call_##m_type##_##m_method(Variant& r_ret,Variant& p_self,const Var
VCALL_LOCALMEM2(ByteArray,set);
VCALL_LOCALMEM1R(ByteArray,get);
VCALL_LOCALMEM1(ByteArray,push_back);
- VCALL_LOCALMEM1(ByteArray,push_front);
- VCALL_LOCALMEM0(ByteArray,pop_back);
- VCALL_LOCALMEM0(ByteArray,pop_front);
VCALL_LOCALMEM1(ByteArray,resize);
VCALL_LOCALMEM1(ByteArray,append);
VCALL_LOCALMEM1(ByteArray,append_array);
@@ -1432,12 +1429,15 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl
ADDFUNC0(ARRAY,NIL,Array,clear,varray());
ADDFUNC0(ARRAY,INT,Array,hash,varray());
ADDFUNC1(ARRAY,NIL,Array,push_back,NIL,"value",varray());
+ ADDFUNC1(ARRAY,NIL,Array,push_front,NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,append,NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,resize,INT,"pos",varray());
ADDFUNC2(ARRAY,NIL,Array,insert,INT,"pos",NIL,"value",varray());
ADDFUNC1(ARRAY,NIL,Array,remove,INT,"pos",varray());
ADDFUNC1(ARRAY,NIL,Array,erase,NIL,"value",varray());
ADDFUNC1(ARRAY,INT,Array,find,NIL,"value",varray());
+ ADDFUNC0(ARRAY,NIL,Array,pop_back,varray());
+ ADDFUNC0(ARRAY,NIL,Array,pop_front,varray());
ADDFUNC0(ARRAY,NIL,Array,sort,varray());
ADDFUNC2(ARRAY,NIL,Array,sort_custom,OBJECT,"obj",STRING,"func",varray());
ADDFUNC0(ARRAY,NIL,Array,invert,varray());
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 20f28ecf10..25e39c1891 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -524,7 +524,7 @@ void PopupMenu::add_icon_item(const Ref<Texture>& p_icon,const String& p_label,i
item.icon=p_icon;
item.text=p_label;
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -533,7 +533,7 @@ void PopupMenu::add_item(const String& p_label,int p_ID,uint32_t p_accel) {
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
items.push_back(item);
update();
}
@@ -542,7 +542,7 @@ void PopupMenu::add_submenu_item(const String& p_label, const String& p_submenu,
Item item;
item.text=XL_MESSAGE(p_label);
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.submenu=p_submenu;
items.push_back(item);
update();
@@ -554,7 +554,7 @@ void PopupMenu::add_icon_check_item(const Ref<Texture>& p_icon,const String& p_l
item.icon=p_icon;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -564,7 +564,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
Item item;
item.text=XL_MESSAGE(p_label);
item.accel=p_accel;
- item.ID=(p_ID<0)?idcount++:p_ID;
+ item.ID=p_ID;
item.checkable=true;
items.push_back(item);
update();
@@ -755,7 +755,8 @@ void PopupMenu::activate_item(int p_item) {
ERR_FAIL_INDEX(p_item,items.size());
ERR_FAIL_COND(items[p_item].separator);
- emit_signal("item_pressed",items[p_item].ID);
+ int id = items[p_item].ID>=0?items[p_item].ID:p_item;
+ emit_signal("item_pressed",id);
//hide all parent PopupMenue's
Node *next = get_parent();
@@ -789,7 +790,7 @@ void PopupMenu::clear() {
items.clear();
mouse_over=-1;
update();
- idcount=0;
+
}
@@ -937,7 +938,7 @@ void PopupMenu::set_invalidate_click_until_motion() {
PopupMenu::PopupMenu() {
- idcount=0;
+
mouse_over=-1;
set_focus_mode(FOCUS_ALL);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index ed78fe6738..30223469a3 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -59,7 +59,6 @@ class PopupMenu : public Popup {
Timer *submenu_timer;
List<Rect2> autohide_areas;
Vector<Item> items;
- int idcount;
int mouse_over;
int submenu_over;
Rect2 parent_rect;