Merge pull request #6545 from Hinsbart/textedit

Fix ability to cut/paste text in LineEdit/TextEdit in readonly mode.

[ci skip]
This commit is contained in:
Rémi Verschelde 2016-09-19 14:25:48 +02:00 committed by GitHub
commit 829d69ba52
2 changed files with 24 additions and 12 deletions

View file

@ -1191,24 +1191,28 @@ void LineEdit::menu_option(int p_option) {
switch(p_option) { switch(p_option) {
case MENU_CUT: { case MENU_CUT: {
if (editable) {
cut_text(); cut_text();
}
} break; } break;
case MENU_COPY: { case MENU_COPY: {
copy_text(); copy_text();
} break; } break;
case MENU_PASTE: { case MENU_PASTE: {
if (editable) {
paste_text(); paste_text();
}
} break; } break;
case MENU_CLEAR: { case MENU_CLEAR: {
if (editable) {
clear(); clear();
}
} break; } break;
case MENU_SELECT_ALL: { case MENU_SELECT_ALL: {
select_all(); select_all();
} break; } break;
case MENU_UNDO: { case MENU_UNDO: {
undo(); undo();
} break; } break;

View file

@ -2542,7 +2542,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
} break; } break;
case KEY_X: { case KEY_X: {
if (readonly) {
break;
}
if (!k.mod.command || k.mod.shift || k.mod.alt) { if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false; scancode_handled=false;
break; break;
@ -2574,7 +2576,9 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
undo(); undo();
} break; } break;
case KEY_V: { case KEY_V: {
if (readonly) {
break;
}
if (!k.mod.command || k.mod.shift || k.mod.alt) { if (!k.mod.command || k.mod.shift || k.mod.alt) {
scancode_handled=false; scancode_handled=false;
break; break;
@ -4527,18 +4531,22 @@ void TextEdit::menu_option(int p_option) {
switch( p_option ) { switch( p_option ) {
case MENU_CUT: { case MENU_CUT: {
if (!readonly) {
cut(); cut();
}
} break; } break;
case MENU_COPY: { case MENU_COPY: {
copy(); copy();
} break; } break;
case MENU_PASTE: { case MENU_PASTE: {
if (!readonly) {
paste(); paste();
}
} break; } break;
case MENU_CLEAR: { case MENU_CLEAR: {
if (!readonly) {
clear(); clear();
}
} break; } break;
case MENU_SELECT_ALL: { case MENU_SELECT_ALL: {
select_all(); select_all();