bool ItemListPlugin::_get(const StringName& p_name,Variant &r_ret) const {

	String name = p_name;
	int idx = name.get_slice("/",0).to_int();
	String what=name.get_slice("/",1);

	if (what=="text")
		r_ret=get_item_text(idx);
	else if (what=="icon")
		r_ret=get_item_icon(idx);
	else if (what=="checkable")
		r_ret=is_item_checkable(idx);
	else if (what=="checked")
		r_ret=is_item_checked(idx);
	else if (what=="id")
		r_ret=get_item_id(idx);
	else if (what=="enabled")
		r_ret=is_item_enabled(idx);
	else if (what=="separator")
		r_ret=is_item_separator(idx);
	else
		return false;

	return true;
}
bool ItemListPlugin::_get(const StringName &p_name, Variant &r_ret) const {

	String name = p_name;
	int idx = name.get_slice("/", 0).to_int();
	String what = name.get_slice("/", 1);

	if (what == "text")
		r_ret = get_item_text(idx);
	else if (what == "icon")
		r_ret = get_item_icon(idx);
	else if (what == "checkable") {
		// This keeps compatibility to/from versions where this property was a boolean, before radio buttons
		if (!is_item_checkable(idx)) {
			r_ret = 0;
		} else {
			r_ret = is_item_radio_checkable(idx) ? 2 : 1;
		}
	} else if (what == "checked")
		r_ret = is_item_checked(idx);
	else if (what == "id")
		r_ret = get_item_id(idx);
	else if (what == "enabled")
		r_ret = is_item_enabled(idx);
	else if (what == "separator")
		r_ret = is_item_separator(idx);
	else
		return false;

	return true;
}
Exemplo n.º 3
0
Array PopupMenu::_get_items() const {

	Array items;
	for (int i = 0; i < get_item_count(); i++) {

		items.push_back(get_item_text(i));
		items.push_back(get_item_icon(i));
		items.push_back(is_item_checkable(i));
		items.push_back(is_item_checked(i));
		items.push_back(is_item_disabled(i));

		items.push_back(get_item_id(i));
		items.push_back(get_item_accelerator(i));
		items.push_back(get_item_metadata(i));
		items.push_back(get_item_submenu(i));
		items.push_back(is_item_separator(i));
	}

	return items;
}
Exemplo n.º 4
0
Array PopupMenu::_get_items() const {

	Array items;
	for (int i = 0; i < get_item_count(); i++) {

		items.push_back(get_item_text(i));
		items.push_back(get_item_icon(i));
		// For compatibility, use false/true for no/checkbox and integers for other values
		int ct = this->items[i].checkable_type;
		items.push_back(Variant(ct <= Item::CHECKABLE_TYPE_CHECK_BOX ? is_item_checkable(i) : ct));
		items.push_back(is_item_checked(i));
		items.push_back(is_item_disabled(i));

		items.push_back(get_item_id(i));
		items.push_back(get_item_accelerator(i));
		items.push_back(get_item_metadata(i));
		items.push_back(get_item_submenu(i));
		items.push_back(is_item_separator(i));
	}

	return items;
}