示例#1
0
void PopupMenu::add_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {

	ERR_FAIL_COND(p_shortcut.is_null());

	_ref_shortcut(p_shortcut);

	Item item;
	item.ID = p_ID;
	item.shortcut = p_shortcut;
	item.shortcut_is_global = p_global;
	items.push_back(item);
	update();
}
示例#2
0
void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut> &p_shortcut, bool p_global) {
	ERR_FAIL_INDEX(p_idx, items.size());
	if (items[p_idx].shortcut.is_valid()) {
		_unref_shortcut(items[p_idx].shortcut);
	}
	items[p_idx].shortcut = p_shortcut;
	items[p_idx].shortcut_is_global = p_global;

	if (items[p_idx].shortcut.is_valid()) {
		_ref_shortcut(items[p_idx].shortcut);
	}

	update();
}
示例#3
0
void PopupMenu::add_check_shortcut(const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {

	ERR_FAIL_COND(p_shortcut.is_null());

	_ref_shortcut(p_shortcut);

	Item item;
	item.ID = p_ID;
	item.shortcut = p_shortcut;
	item.shortcut_is_global = p_global;
	item.checkable_type = Item::CHECKABLE_TYPE_CHECK_BOX;
	items.push_back(item);
	update();
}
示例#4
0
void PopupMenu::add_icon_check_shortcut(const Ref<Texture> &p_icon, const Ref<ShortCut> &p_shortcut, int p_ID, bool p_global) {

	ERR_FAIL_COND(p_shortcut.is_null());

	_ref_shortcut(p_shortcut);

	Item item;
	item.ID = p_ID;
	item.shortcut = p_shortcut;
	item.checkable = true;
	item.icon = p_icon;
	item.shortcut_is_global = p_global;
	items.push_back(item);
	update();
}