start a new line with "Shift + Enter"

Text tool:
* Enter: valid text and close text entry.
* Escape: close text entry.
* Shift + Enter: Start a new line.

related to #30.
This commit is contained in:
abakkk 2020-10-12 11:09:20 +02:00
parent cddfa3172f
commit 9731ebecb7
2 changed files with 12 additions and 6 deletions

16
area.js
View File

@ -802,8 +802,8 @@ var DrawingArea = new Lang.Class({
this.currentElement.text = ''; this.currentElement.text = '';
this.currentElement.cursorPosition = 0; this.currentElement.cursorPosition = 0;
// Translators: %s is a key label // Translators: %s is a key label
this.emit('show-osd', Files.Icons.TOOL_TEXT, _("Type your text and press <i>%s</i>") this.emit('show-osd', Files.Icons.TOOL_TEXT, _("Press <i>%s</i>\nto start a new line")
.format(Gtk.accelerator_get_label(Clutter.KEY_Escape, 0)), "", -1, true); .format(Gtk.accelerator_get_label(Clutter.KEY_Return, 1)), "", -1, true);
this._updateTextCursorTimeout(); this._updateTextCursorTimeout();
this.textHasCursor = true; this.textHasCursor = true;
this._redisplay(); this._redisplay();
@ -828,9 +828,7 @@ var DrawingArea = new Lang.Class({
} }
this.textEntry.clutterText.connect('activate', (clutterText) => { this.textEntry.clutterText.connect('activate', (clutterText) => {
let startNewLine = true; this._stopWriting();
this._stopWriting(startNewLine);
clutterText.text = "";
}); });
this.textEntry.clutterText.connect('text-changed', (clutterText) => { this.textEntry.clutterText.connect('text-changed', (clutterText) => {
@ -844,8 +842,16 @@ var DrawingArea = new Lang.Class({
this.textEntry.clutterText.connect('key-press-event', (clutterText, event) => { this.textEntry.clutterText.connect('key-press-event', (clutterText, event) => {
if (event.get_key_symbol() == Clutter.KEY_Escape) { if (event.get_key_symbol() == Clutter.KEY_Escape) {
this.currentElement.text = "";
this._stopWriting(); this._stopWriting();
return Clutter.EVENT_STOP; return Clutter.EVENT_STOP;
} else if (event.has_shift_modifier() &&
(event.get_key_symbol() == Clutter.KEY_Return ||
event.get_key_symbol() == Clutter.KEY_KP_Enter)) {
let startNewLine = true;
this._stopWriting(startNewLine);
clutterText.text = "";
return Clutter.EVENT_STOP;
} }
// 'cursor-changed' signal is not emitted if the text entry is not visible. // 'cursor-changed' signal is not emitted if the text entry is not visible.

View File

@ -44,7 +44,7 @@ msgstr ""
#. Translators: %s is a key label #. Translators: %s is a key label
#, javascript-format #, javascript-format
msgid "Type your text and press <i>%s</i>" msgid "Press <i>%s</i>\nto start a new line"
msgstr "" msgstr ""
#. Translators: It is displayed in an OSD notification to ask the user to start picking, so it should use the imperative mood. #. Translators: It is displayed in an OSD notification to ask the user to start picking, so it should use the imperative mood.