summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJ08nY <johny@neuromancer.sk>2016-10-01 15:50:54 +0200
committerJ08nY <johny@neuromancer.sk>2016-10-01 16:50:53 +0200
commit6b283ae2931475cfda8f5f24307ca01998b6e813 (patch)
tree7637c2aed986c5d19ed0ffcf7570f9e4e62269e0
parent3ecd8560fd90a615d80a447b04e713bb2c600fe4 (diff)
PopupMenu: added toggle_item_checked and exposed set_item_tooltip and get_item_tooltip
-rw-r--r--scene/gui/popup_menu.cpp38
-rw-r--r--scene/gui/popup_menu.h2
2 files changed, 27 insertions, 13 deletions
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index b3f18bf8fa..2fbb093e8e 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -701,6 +701,13 @@ void PopupMenu::set_item_submenu(int p_idx, const String& p_submenu) {
update();
}
+void PopupMenu::toggle_item_checked(int p_idx) {
+
+ ERR_FAIL_INDEX(p_idx,items.size());
+ items[p_idx].checked = !items[p_idx].checked;
+ update();
+}
+
String PopupMenu::get_item_text(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx,items.size(),"");
@@ -1061,33 +1068,40 @@ void PopupMenu::_bind_methods() {
ObjectTypeDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
ObjectTypeDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
-
ObjectTypeDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
ObjectTypeDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
+ ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
+ ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
ObjectTypeDB::bind_method(_MD("set_item_accelerator","idx","accel"),&PopupMenu::set_item_accelerator);
ObjectTypeDB::bind_method(_MD("set_item_metadata","idx","metadata"),&PopupMenu::set_item_metadata);
- ObjectTypeDB::bind_method(_MD("set_item_checked","idx","checked"),&PopupMenu::set_item_checked);
ObjectTypeDB::bind_method(_MD("set_item_disabled","idx","disabled"),&PopupMenu::set_item_disabled);
- ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
ObjectTypeDB::bind_method(_MD("set_item_submenu","idx","submenu"),&PopupMenu::set_item_submenu);
ObjectTypeDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
ObjectTypeDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
- ObjectTypeDB::bind_method(_MD("set_item_ID","idx","id"),&PopupMenu::set_item_ID);
+ ObjectTypeDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
+
+ ObjectTypeDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
+
ObjectTypeDB::bind_method(_MD("get_item_text","idx"),&PopupMenu::get_item_text);
ObjectTypeDB::bind_method(_MD("get_item_icon","idx"),&PopupMenu::get_item_icon);
- ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
+ ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
+ ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
ObjectTypeDB::bind_method(_MD("get_item_accelerator","idx"),&PopupMenu::get_item_accelerator);
- ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+ ObjectTypeDB::bind_method(_MD("get_item_metadata","idx"),&PopupMenu::get_item_metadata);
+ ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
ObjectTypeDB::bind_method(_MD("get_item_submenu","idx"),&PopupMenu::get_item_submenu);
ObjectTypeDB::bind_method(_MD("is_item_separator","idx"),&PopupMenu::is_item_separator);
ObjectTypeDB::bind_method(_MD("is_item_checkable","idx"),&PopupMenu::is_item_checkable);
- ObjectTypeDB::bind_method(_MD("is_item_checked","idx"),&PopupMenu::is_item_checked);
- ObjectTypeDB::bind_method(_MD("is_item_disabled","idx"),&PopupMenu::is_item_disabled);
- ObjectTypeDB::bind_method(_MD("get_item_ID","idx"),&PopupMenu::get_item_ID);
- ObjectTypeDB::bind_method(_MD("get_item_index","id"),&PopupMenu::get_item_index);
+ ObjectTypeDB::bind_method(_MD("get_item_tooltip","idx"),&PopupMenu::get_item_tooltip);
+ ObjectTypeDB::bind_method(_MD("get_item_shortcut:ShortCut","idx"),&PopupMenu::get_item_shortcut);
+
ObjectTypeDB::bind_method(_MD("get_item_count"),&PopupMenu::get_item_count);
- ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
+
ObjectTypeDB::bind_method(_MD("remove_item","idx"),&PopupMenu::remove_item);
+
+ ObjectTypeDB::bind_method(_MD("add_separator"),&PopupMenu::add_separator);
ObjectTypeDB::bind_method(_MD("clear"),&PopupMenu::clear);
ObjectTypeDB::bind_method(_MD("_set_items"),&PopupMenu::_set_items);
@@ -1125,5 +1139,3 @@ PopupMenu::PopupMenu() {
PopupMenu::~PopupMenu() {
}
-
-
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index f35e91d4e4..b3e8cd2713 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -116,6 +116,8 @@ public:
void set_item_tooltip(int p_idx,const String& p_tooltip);
void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void toggle_item_checked(int p_idx);
+
String get_item_text(int p_idx) const;
Ref<Texture> get_item_icon(int p_idx) const;
bool is_item_checked(int p_idx) const;