mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
Fixes #2453. TextField OnEnter throws exception if IsInitialized is false.
This commit is contained in:
@@ -663,7 +663,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
{
|
||||
bool cancel = true;
|
||||
|
||||
_textField.TextChanging += (s,e) => {
|
||||
_textField.TextChanging += (s, e) => {
|
||||
Assert.Equal ("changing", e.NewText);
|
||||
if (cancel) {
|
||||
e.Cancel = true;
|
||||
@@ -681,7 +681,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
[TextFieldTestsAutoInitShutdown]
|
||||
public void TextChanged_Event ()
|
||||
{
|
||||
_textField.TextChanged += (s,e) => {
|
||||
_textField.TextChanged += (s, e) => {
|
||||
Assert.Equal ("TAB to jump between text fields.", e.OldValue);
|
||||
};
|
||||
|
||||
@@ -781,7 +781,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
Assert.Equal ("A", tf.Text.ToString ());
|
||||
|
||||
// cancel the next keystroke
|
||||
tf.TextChanging += (s,e) => e.Cancel = e.NewText == "AB";
|
||||
tf.TextChanging += (s, e) => e.Cancel = e.NewText == "AB";
|
||||
tf.ProcessKey (new KeyEvent (Key.B, new KeyModifiers ()));
|
||||
|
||||
// B was canceled so should just be A
|
||||
@@ -1137,7 +1137,7 @@ namespace Terminal.Gui.ViewTests {
|
||||
var oldText = "";
|
||||
var tf = new TextField () { Width = 10, Text = "-1" };
|
||||
|
||||
tf.TextChanging += (s,e) => newText = e.NewText.ToString ();
|
||||
tf.TextChanging += (s, e) => newText = e.NewText.ToString ();
|
||||
tf.TextChanged += (s, e) => oldText = e.OldValue.ToString ();
|
||||
|
||||
Application.Top.Add (tf);
|
||||
@@ -1440,5 +1440,16 @@ Les Miśerables", output);
|
||||
TestHelpers.AssertDriverContentsWithFrameAre (@"
|
||||
ắ", output);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void OnEnter_Does_Not_Throw_If_Not_IsInitialized_SetCursorVisibility ()
|
||||
{
|
||||
var top = new Toplevel ();
|
||||
var tf = new TextField () { Width = 10 };
|
||||
top.Add (tf);
|
||||
|
||||
var exception = Record.Exception (tf.SetFocus);
|
||||
Assert.Null (exception);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user