Skip to content
20 changes: 16 additions & 4 deletions h2d/RenderContext.hx
Original file line number Diff line number Diff line change
Expand Up @@ -544,10 +544,22 @@ class RenderContext extends h3d.impl.RenderContext {
var ry1 = x * fb.x + y * fb.y + fb.z;
var rx2 = x2 * fa.x + y2 * fa.y + fa.z;
var ry2 = x2 * fb.x + y2 * fb.y + fb.z;
x = rx1;
y = ry1;
w = rx2 - rx1;
h = ry2 - ry1;
// The filter matrix lands in the filter texture's own pixels (it already
// carries the filter's resolution), but measured from the filtered
// object's origin, while the texture starts at the (xMin, yMin) it was
// pushed with (Object.drawFilters) - which pushTarget folded into
// viewX/viewY. Measured from the scene viewport instead, the zone sat
// that far off (a blur's boundsExtend, 2px up and left) and scaled
// a second time by the viewport.
var startX = -(viewX + 1) / viewA;
var startY = -(viewY + 1) / viewD;
engine.setRenderZone(
Std.int(rx1 - startX + 1e-10),
Std.int(ry1 - startY + 1e-10),
Std.int(rx2 - rx1 + 1e-10),
Std.int(ry2 - ry1 + 1e-10)
);
return;
}

engine.setRenderZone(
Expand Down
4 changes: 3 additions & 1 deletion 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 Expand Up @@ -385,7 +387,7 @@ class Text extends Drawable {
x += esize;
prevChar = cc;
if( lineBreak ) {
if( x > maxWidth && lastBreak >= 0 && (!trimTrailingSpaces || !font.charset.isSpace(cc) || startX > maxWidth) ) {
if( x > maxWidth && lastBreak >= lastPos && (!trimTrailingSpaces || !font.charset.isSpace(cc) || startX > maxWidth) ) {
i = lastBreak;
x = lastBreakX;
flushLine(i + 1);
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