Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions h2d/Text.hx
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ class Text extends Drawable {
} else {
maxWidth -= afterData;
}
if (maxWidth <= 2)
return text;
if ( font == null ) font = this.font;
var lines = [];
var x = leftMargin;
Expand Down
12 changes: 8 additions & 4 deletions h2d/TextInput.hx
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,11 @@ class TextInput extends Text {
return;
case K.C if (K.isDown(K.CTRL)):
if( text != "" && selectionRange != null ) {
hxd.System.setClipboardText(text.substr(selectionRange.start, selectionRange.length));
hxd.System.setClipboardText(getSelectedText());
}
case K.X if (K.isDown(K.CTRL)):
if( text != "" && selectionRange != null ) {
if(hxd.System.setClipboardText(text.substr(selectionRange.start, selectionRange.length))) {
if(hxd.System.setClipboardText(getSelectedText())) {
if( !canEdit ) return;
beforeChange();
cutSelection();
Expand Down Expand Up @@ -435,9 +435,13 @@ class TextInput extends Text {
if (cursorIndex >= len) {
return len;
}
// ret walks the text itself, so it stops at the end of the TEXT: getTextLength
// is the expanded length, longer than the text by one per inserted line break,
// and bounding a text position with it runs past the end.
var max = text.length;
var ret = getTextPos(cursorIndex);
while (ret < len && isWordLimit(ret)) ret++;
while (ret < len && !isWordLimit(ret)) ret++;
while (ret < max && isWordLimit(ret)) ret++;
while (ret < max && !isWordLimit(ret)) ret++;
return getCursorPos(ret);
}

Expand Down