make popup emit index when id is not defined

This commit is contained in:
Juan Linietsky 2015-12-12 09:07:43 -03:00
parent b191e740d2
commit 9a7ff65751
3 changed files with 12 additions and 12 deletions

View file

@ -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());

View file

@ -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);

View file

@ -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;