Skip to content

Commit 404d954

Browse files
authored
Merge pull request #62 from Shallowmallow/TextFieldCloneFix
Textfield clone fix
2 parents 25e32b8 + 4faa021 commit 404d954

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

haxe/ui/backend/TextDisplayImpl.hx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,25 +9,33 @@ class TextDisplayImpl extends TextBase {
99

1010
private override function get_selectionStartIndex():Int {
1111
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
12+
if (textCtrl == null) return 0;
13+
1214
return textCtrl.selection.start;
1315
}
1416

1517
private override function set_selectionStartIndex(value:Int):Int {
1618
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
17-
var endIndex = selectionEndIndex < value ? value : selectionEndIndex; // otherwise hxWigets changes start to end
19+
if (textCtrl == null) return 0;
20+
21+
var endIndex = selectionEndIndex < value ? value : selectionEndIndex; // otherwise hxWigets changes start to end
1822
textCtrl.selection = {start: value, end: endIndex};
1923
return value;
2024
}
2125

2226

2327
private override function get_selectionEndIndex():Int {
2428
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
29+
if (textCtrl == null) return 0;
30+
2531
return textCtrl.selection.end;
2632
}
2733

2834
private override function set_selectionEndIndex(value:Int):Int {
2935
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
30-
textCtrl.selection = {start: selectionStartIndex, end: value};
36+
if (textCtrl == null) return 0;
37+
38+
textCtrl.selection = {start: selectionStartIndex, end: value};
3139
return value;
3240
}
3341
}

0 commit comments

Comments
 (0)