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
This commit is contained in:
Andreas Haas 2016-09-29 09:12:45 +02:00
parent 5e7db2a5b4
commit f81d009525
No known key found for this signature in database
GPG key ID: B5FFAE1B65FBD2E1
4 changed files with 132 additions and 6 deletions

View file

@ -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);