summaryrefslogtreecommitdiff
path: root/scene/gui
diff options
context:
space:
mode:
authorAndreas Haas <liu.gam3@gmail.com>2016-09-29 09:12:45 +0200
committerAndreas Haas <liu.gam3@gmail.com>2016-09-29 09:12:45 +0200
commitf81d0095259c3affeec0de79e4ad1f38ea9bba39 (patch)
tree04c052636e2aed98b5d82b6e433ea8498e546c71 /scene/gui
parent5e7db2a5b47a66337517b01e5d43ac87a0ac70b3 (diff)
Add inline ColorPicker to Script text editor.
Adds an option to the script editor context menu that lets you open a ColorPicker in order to easily edit `Color()` constructors. To do this, right click on the word `Color` and select `Pick Color`. A side effect of this change is that the script editor now has its own context menu instead of re-using the one from TextEdit. It's now possible to indent left/right and to toggle comments via this menu. I also felt free to make it more context-sensitive than before: Now "Cut" and "Copy" will only be shown if text has actually been selected. I also added default shortcuts for indent left/right. (alt + left/right) Closes #6232
Diffstat (limited to 'scene/gui')
-rw-r--r--scene/gui/text_edit.cpp6
-rw-r--r--scene/gui/text_edit.h7
2 files changed, 10 insertions, 3 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp
index 8a9ed98a5f..14508e07a8 100644
--- a/scene/gui/text_edit.cpp
+++ b/scene/gui/text_edit.cpp
@@ -1651,7 +1651,7 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
update();
}
- if (mb.button_index==BUTTON_RIGHT) {
+ if (mb.button_index==BUTTON_RIGHT && context_menu_enabled) {
menu->set_pos(get_global_transform().xform(get_local_mouse_pos()));
menu->set_size(Vector2(1,1));
@@ -4569,6 +4569,9 @@ bool TextEdit::is_selecting_identifiers_on_hover_enabled() const {
return select_identifiers_enabled;
}
+void TextEdit::set_context_menu_enabled(bool p_enable) {
+ context_menu_enabled = p_enable;
+}
PopupMenu *TextEdit::get_menu() const {
return menu;
@@ -4789,6 +4792,7 @@ TextEdit::TextEdit() {
window_has_focus=true;
select_identifiers_enabled=false;
+ context_menu_enabled=true;
menu = memnew( PopupMenu );
add_child(menu);
menu->add_item(TTR("Cut"),MENU_CUT,KEY_MASK_CMD|KEY_X);
diff --git a/scene/gui/text_edit.h b/scene/gui/text_edit.h
index cb49618f18..37477e3b7e 100644
--- a/scene/gui/text_edit.h
+++ b/scene/gui/text_edit.h
@@ -269,6 +269,8 @@ class TextEdit : public Control {
int search_result_line;
int search_result_col;
+ bool context_menu_enabled;
+
int get_visible_rows() const;
int get_char_count();
@@ -319,8 +321,6 @@ class TextEdit : public Control {
void _confirm_completion();
void _update_completion_candidates();
- void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
-
protected:
virtual String get_tooltip(const Point2& p_pos) const;
@@ -360,6 +360,8 @@ public:
virtual CursorShape get_cursor_shape(const Point2& p_pos=Point2i()) const;
+ void _get_mouse_pos(const Point2i& p_mouse, int &r_row, int &r_col) const;
+
//void delete_char();
//void delete_line();
@@ -499,6 +501,7 @@ public:
void set_select_identifiers_on_hover(bool p_enable);
bool is_selecting_identifiers_on_hover_enabled() const;
+ void set_context_menu_enabled(bool p_enable);
PopupMenu *get_menu() const;
String get_text_for_completion();