mirror of
https://github.com/Ellpeck/MLEM.git
synced 2024-11-22 20:58:34 +01:00
fixed text field crash when pasting an empty clipboard
This commit is contained in:
parent
98a7e3b633
commit
c92e4e0fd1
1 changed files with 5 additions and 3 deletions
|
@ -118,10 +118,10 @@ namespace MLEM.Ui.Elements {
|
||||||
// handle first initialization if not done
|
// handle first initialization if not done
|
||||||
if (this.displayedText == null)
|
if (this.displayedText == null)
|
||||||
this.HandleTextChange(false);
|
this.HandleTextChange(false);
|
||||||
|
|
||||||
if (!this.IsSelected || this.IsHidden)
|
if (!this.IsSelected || this.IsHidden)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.Input.IsKeyPressed(Keys.Left)) {
|
if (this.Input.IsKeyPressed(Keys.Left)) {
|
||||||
this.CaretPos--;
|
this.CaretPos--;
|
||||||
} else if (this.Input.IsKeyPressed(Keys.Right)) {
|
} else if (this.Input.IsKeyPressed(Keys.Right)) {
|
||||||
|
@ -132,7 +132,9 @@ namespace MLEM.Ui.Elements {
|
||||||
this.CaretPos = this.text.Length;
|
this.CaretPos = this.text.Length;
|
||||||
} else if (this.Input.IsModifierKeyDown(ModifierKey.Control)) {
|
} else if (this.Input.IsModifierKeyDown(ModifierKey.Control)) {
|
||||||
if (this.Input.IsKeyPressed(Keys.V)) {
|
if (this.Input.IsKeyPressed(Keys.V)) {
|
||||||
this.InsertText(Clipboard.GetText());
|
var clip = Clipboard.GetText();
|
||||||
|
if (clip != null)
|
||||||
|
this.InsertText(clip);
|
||||||
} else if (this.Input.IsKeyPressed(Keys.C)) {
|
} else if (this.Input.IsKeyPressed(Keys.C)) {
|
||||||
// until there is text selection, just copy the whole content
|
// until there is text selection, just copy the whole content
|
||||||
Clipboard.SetText(this.Text);
|
Clipboard.SetText(this.Text);
|
||||||
|
|
Loading…
Reference in a new issue