diff options
| author | Andreas Haas | 2016-09-29 09:12:45 +0200 |
|---|---|---|
| committer | Andreas Haas | 2016-09-29 09:12:45 +0200 |
| commit | f81d0095259c3affeec0de79e4ad1f38ea9bba39 (patch) | |
| tree | 04c052636e2aed98b5d82b6e433ea8498e546c71 /scene/gui/text_edit.cpp | |
| parent | 5e7db2a5b47a66337517b01e5d43ac87a0ac70b3 (diff) | |
| download | godot-f81d0095259c3affeec0de79e4ad1f38ea9bba39.tar.gz godot-f81d0095259c3affeec0de79e4ad1f38ea9bba39.tar.zst godot-f81d0095259c3affeec0de79e4ad1f38ea9bba39.zip | |
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/text_edit.cpp')
| -rw-r--r-- | scene/gui/text_edit.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/scene/gui/text_edit.cpp b/scene/gui/text_edit.cpp index 8a9ed98a5..14508e07a 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); |
