summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/item_list.cpp8
-rw-r--r--scene/gui/menu_button.cpp6
-rw-r--r--scene/gui/popup_menu.cpp32
-rw-r--r--scene/gui/popup_menu.h15
-rw-r--r--scene/gui/text_edit.cpp3
-rw-r--r--scene/gui/tree.cpp2
6 files changed, 37 insertions, 29 deletions
diff --git a/scene/gui/item_list.cpp b/scene/gui/item_list.cpp
index 74d78392b1..d16a647fca 100644
--- a/scene/gui/item_list.cpp
+++ b/scene/gui/item_list.cpp
@@ -578,7 +578,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current-1;i>=0;i--) {
@@ -614,7 +614,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- if (diff<int(Globals::get_singleton()->get("gui/incr_search_max_interval_msec"))*2) {
+ if (diff<int(GlobalConfig::get_singleton()->get("gui/timers/incremental_search_max_interval_msec"))*2) {
for(int i=current+1;i<items.size();i++) {
@@ -725,7 +725,7 @@ void ItemList::_input_event(const InputEvent& p_event) {
uint64_t now = OS::get_singleton()->get_ticks_msec();
uint64_t diff = now-search_time_msec;
- uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000));
+ uint64_t max_interval = uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000));
search_time_msec = now;
if (diff>max_interval) {
@@ -1372,6 +1372,8 @@ void ItemList::_bind_methods(){
ADD_SIGNAL( MethodInfo("item_rmb_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::VECTOR2,"atpos")));
ADD_SIGNAL( MethodInfo("multi_selected",PropertyInfo(Variant::INT,"index"),PropertyInfo(Variant::BOOL,"selected")));
ADD_SIGNAL( MethodInfo("item_activated",PropertyInfo(Variant::INT,"index")));
+
+ GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000);
}
ItemList::ItemList() {
diff --git a/scene/gui/menu_button.cpp b/scene/gui/menu_button.cpp
index 44d315eedc..372e4657e1 100644
--- a/scene/gui/menu_button.cpp
+++ b/scene/gui/menu_button.cpp
@@ -39,11 +39,9 @@ void MenuButton::_unhandled_key_input(InputEvent p_event) {
if (!get_parent() || !is_visible() || is_disabled())
return;
- if (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this))
- return; //ignore because of modal window
+ bool global_only = (get_viewport()->get_modal_stack_top() && !get_viewport()->get_modal_stack_top()->is_a_parent_of(this));
-
- if (popup->activate_item_by_event(p_event))
+ if (popup->activate_item_by_event(p_event,global_only))
accept_event();
}
}
diff --git a/scene/gui/popup_menu.cpp b/scene/gui/popup_menu.cpp
index 8686156a8e..e4a03f6e2b 100644
--- a/scene/gui/popup_menu.cpp
+++ b/scene/gui/popup_menu.cpp
@@ -585,7 +585,7 @@ void PopupMenu::add_check_item(const String& p_label,int p_ID,uint32_t p_accel)
}
-void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID) {
+void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon, const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global) {
ERR_FAIL_COND(p_shortcut.is_null());
@@ -595,12 +595,13 @@ void PopupMenu::add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>
item.ID=p_ID;
item.icon=p_icon;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -609,11 +610,12 @@ void PopupMenu::add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID){
+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());
@@ -624,11 +626,12 @@ void PopupMenu::add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<Sho
item.shortcut=p_shortcut;
item.checkable=true;
item.icon=p_icon;
+ item.shortcut_is_global=p_global;
items.push_back(item);
update();
}
-void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
+void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut, int p_ID, bool p_global){
ERR_FAIL_COND(p_shortcut.is_null());
@@ -637,6 +640,7 @@ void PopupMenu::add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID){
Item item;
item.ID=p_ID;
item.shortcut=p_shortcut;
+ item.shortcut_is_global=p_global;
item.checkable=true;
items.push_back(item);
update();
@@ -815,12 +819,14 @@ void PopupMenu::set_item_tooltip(int p_idx,const String& p_tooltip) {
update();
}
-void PopupMenu::set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut) {
+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);
@@ -849,7 +855,7 @@ int PopupMenu::get_item_count() const {
return items.size();
}
-bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
+bool PopupMenu::activate_item_by_event(const InputEvent& p_event, bool p_for_global_only) {
uint32_t code=0;
if (p_event.type==InputEvent::KEY) {
@@ -873,7 +879,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
continue;
- if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event)) {
+ if (items[i].shortcut.is_valid() && items[i].shortcut->is_shortcut(p_event) && (items[i].shortcut_is_global || !p_for_global_only)) {
activate_item(i);
return true;
}
@@ -892,7 +898,7 @@ bool PopupMenu::activate_item_by_event(const InputEvent& p_event) {
if(!pm)
continue;
- if(pm->activate_item_by_event(p_event)) {
+ if(pm->activate_item_by_event(p_event,p_for_global_only)) {
return true;
}
}
@@ -1099,10 +1105,10 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(_MD("add_check_item","label","id","accel"),&PopupMenu::add_check_item,DEFVAL(-1),DEFVAL(0));
ClassDB::bind_method(_MD("add_submenu_item","label","submenu","id"),&PopupMenu::add_submenu_item,DEFVAL(-1));
- ClassDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_shortcut,DEFVAL(-1));
- ClassDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_shortcut,DEFVAL(-1));
- ClassDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1));
- ClassDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id"),&PopupMenu::add_check_shortcut,DEFVAL(-1));
+ ClassDB::bind_method(_MD("add_icon_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_icon_check_shortcut","texture","shortcut:ShortCut","id","global"),&PopupMenu::add_icon_check_shortcut,DEFVAL(-1),DEFVAL(false));
+ ClassDB::bind_method(_MD("add_check_shortcut","shortcut:ShortCut","id","global"),&PopupMenu::add_check_shortcut,DEFVAL(-1),DEFVAL(false));
ClassDB::bind_method(_MD("set_item_text","idx","text"),&PopupMenu::set_item_text);
ClassDB::bind_method(_MD("set_item_icon","idx","icon"),&PopupMenu::set_item_icon);
@@ -1115,7 +1121,7 @@ void PopupMenu::_bind_methods() {
ClassDB::bind_method(_MD("set_item_as_separator","idx","enable"),&PopupMenu::set_item_as_separator);
ClassDB::bind_method(_MD("set_item_as_checkable","idx","enable"),&PopupMenu::set_item_as_checkable);
ClassDB::bind_method(_MD("set_item_tooltip","idx","tooltip"),&PopupMenu::set_item_tooltip);
- ClassDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut"),&PopupMenu::set_item_shortcut);
+ ClassDB::bind_method(_MD("set_item_shortcut","idx","shortcut:ShortCut","global"),&PopupMenu::set_item_shortcut,DEFVAL(false));
ClassDB::bind_method(_MD("toggle_item_checked","idx"), &PopupMenu::toggle_item_checked);
diff --git a/scene/gui/popup_menu.h b/scene/gui/popup_menu.h
index 282e152287..9cc3daa8fe 100644
--- a/scene/gui/popup_menu.h
+++ b/scene/gui/popup_menu.h
@@ -56,8 +56,9 @@ class PopupMenu : public Popup {
int _ofs_cache;
int h_ofs;
Ref<ShortCut> shortcut;
+ bool shortcut_is_global;
- Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; h_ofs=0; }
+ Item() { checked=false; checkable=false; separator=false; accel=0; disabled=false; _ofs_cache=0; h_ofs=0; shortcut_is_global=false; }
};
@@ -100,10 +101,10 @@ public:
void add_check_item(const String& p_label,int p_ID=-1,uint32_t p_accel=0);
void add_submenu_item(const String& p_label,const String& p_submenu, int p_ID=-1);
- void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1);
- void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1);
+ void add_icon_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_icon_check_shortcut(const Ref<Texture>& p_icon,const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
+ void add_check_shortcut(const Ref<ShortCut>& p_shortcut,int p_ID=-1,bool p_global=false);
void set_item_text(int p_idx,const String& p_text);
void set_item_icon(int p_idx,const Ref<Texture>& p_icon);
@@ -116,7 +117,7 @@ public:
void set_item_as_separator(int p_idx, bool p_separator);
void set_item_as_checkable(int p_idx, bool p_checkable);
void set_item_tooltip(int p_idx,const String& p_tooltip);
- void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut);
+ void set_item_shortcut(int p_idx, const Ref<ShortCut>& p_shortcut,bool p_global=false);
void set_item_h_offset(int p_idx, int p_offset);
void toggle_item_checked(int p_idx);
@@ -137,7 +138,7 @@ public:
int get_item_count() const;
- bool activate_item_by_event(const InputEvent& p_event);
+ bool activate_item_by_event(const InputEvent& p_event,bool p_for_global_only=false);
void activate_item(int p_item);
void remove_item(int p_idx);
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 4394f4b237..397edbf3b6 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -4707,6 +4707,7 @@ void TextEdit::_bind_methods() {
BIND_CONSTANT( MENU_MAX );
+ GLOBAL_DEF("gui/timers/text_edit_idle_detect_sec",3);
}
TextEdit::TextEdit() {
@@ -4767,7 +4768,7 @@ TextEdit::TextEdit() {
idle_detect = memnew( Timer );
add_child(idle_detect);
idle_detect->set_one_shot(true);
- idle_detect->set_wait_time(GLOBAL_DEF("display/text_edit_idle_detect_sec",3));
+ idle_detect->set_wait_time(GLOBAL_GET("gui/timers/text_edit_idle_detect_sec"));
idle_detect->connect("timeout", this,"_push_current_op");
click_select_held = memnew( Timer );
diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp
index 40caae48fd..86fe9cd682 100644
--- a/scene/gui/tree.cpp
+++ b/scene/gui/tree.cpp
@@ -3302,7 +3302,7 @@ void Tree::_do_incr_search(const String& p_add) {
uint64_t time = OS::get_singleton()->get_ticks_usec() / 1000; // convert to msec
uint64_t diff = time - last_keypress;
- if (diff > uint64_t(GLOBAL_DEF("gui/incr_search_max_interval_msec",2000)))
+ if (diff > uint64_t(GLOBAL_DEF("gui/timers/incremental_search_max_interval_msec",2000)))
incr_search=p_add;
else
incr_search+=p_add;