Skip to content

Commit

Permalink
Merge pull request #62 from Shallowmallow/TextFieldCloneFix
Browse files Browse the repository at this point in the history
Textfield clone fix
  • Loading branch information
ianharrigan authored Sep 26, 2024
2 parents 25e32b8 + 4faa021 commit 404d954
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions haxe/ui/backend/TextDisplayImpl.hx
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,33 @@ class TextDisplayImpl extends TextBase {

private override function get_selectionStartIndex():Int {
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
if (textCtrl == null) return 0;

return textCtrl.selection.start;
}

private override function set_selectionStartIndex(value:Int):Int {
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
var endIndex = selectionEndIndex < value ? value : selectionEndIndex; // otherwise hxWigets changes start to end
if (textCtrl == null) return 0;

var endIndex = selectionEndIndex < value ? value : selectionEndIndex; // otherwise hxWigets changes start to end
textCtrl.selection = {start: value, end: endIndex};
return value;
}


private override function get_selectionEndIndex():Int {
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
if (textCtrl == null) return 0;

return textCtrl.selection.end;
}

private override function set_selectionEndIndex(value:Int):Int {
var textCtrl:hx.widgets.TextCtrl = cast(this.parentComponent.window, hx.widgets.TextCtrl);
textCtrl.selection = {start: selectionStartIndex, end: value};
if (textCtrl == null) return 0;

textCtrl.selection = {start: selectionStartIndex, end: value};
return value;
}
}

0 comments on commit 404d954

Please sign in to comment.