Merge pull request #4248 from bojidar-bg/fix-launchmedia-for-bones

Fix Ctrl+LaunchMedia showing up as a shortcut for "Make Bones"
This commit is contained in:
Rémi Verschelde 2016-04-06 18:43:15 +02:00
commit d5191a610b
4 changed files with 25 additions and 23 deletions

View File

@ -53,23 +53,7 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
code|=KEY_MASK_SHIFT; code|=KEY_MASK_SHIFT;
int item = popup->find_item_by_accelerator(code); int item = popup->activate_item_by_accelerator(code);
if (item>=0 && ! popup->is_item_disabled(item))
popup->activate_item(item);
/*
for(int i=0;i<items.size();i++) {
if (items[i].accel==0)
continue;
if (items[i].accel==code) {
emit_signal("item_pressed",items[i].ID);
}
}*/
} }
} }

View File

@ -740,15 +740,33 @@ int PopupMenu::get_item_count() const {
return items.size(); return items.size();
} }
int PopupMenu::find_item_by_accelerator(uint32_t p_accel) const { bool PopupMenu::activate_item_by_accelerator(uint32_t p_accel) {
int il=items.size(); int il=items.size();
for(int i=0;i<il;i++) { for(int i=0;i<il;i++) {
if (is_item_disabled(i))
continue;
if (items[i].accel==p_accel) if (items[i].accel==p_accel) {
return i; activate_item(i);
return true;
} }
return -1;
if (items[i].submenu!="") {
Node* n = get_node(items[i].submenu);
if(!n)
continue;
PopupMenu* pm = n->cast_to<PopupMenu>();
if(!pm)
continue;
if(pm->activate_item_by_accelerator(p_accel)) {
return true;
}
}
}
return false;
} }
void PopupMenu::activate_item(int p_item) { void PopupMenu::activate_item(int p_item) {

View File

@ -117,7 +117,7 @@ public:
int get_item_count() const; int get_item_count() const;
int find_item_by_accelerator(uint32_t p_accel) const; bool activate_item_by_accelerator(uint32_t p_accel);
void activate_item(int p_item); void activate_item(int p_item);
void remove_item(int p_idx); void remove_item(int p_idx);

View File

@ -3345,7 +3345,7 @@ CanvasItemEditor::CanvasItemEditor(EditorNode *p_editor) {
PopupMenu *p2 = memnew(PopupMenu); PopupMenu *p2 = memnew(PopupMenu);
p->add_child(p2); p->add_child(p2);
p2->set_name("skeleton"); p2->set_name("skeleton");
p2->add_item("Make Bones",SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_SHIFT|KEY_B); p2->add_item("Make Bones",SKELETON_MAKE_BONES,KEY_MASK_CMD|KEY_MASK_SHIFT|KEY_B);
p2->add_item("Clear Bones",SKELETON_CLEAR_BONES); p2->add_item("Clear Bones",SKELETON_CLEAR_BONES);
p2->add_separator(); p2->add_separator();
p2->add_item("Make IK Chain",SKELETON_SET_IK_CHAIN); p2->add_item("Make IK Chain",SKELETON_SET_IK_CHAIN);