mirror of
https://github.com/gui-cs/Terminal.Gui.git
synced 2026-01-02 01:03:29 +01:00
* Fixes #1475. Selection ending with a white space error. * Prevents the mouse double click processing twice. * Removing unnecessary variable. * Sets ScrollViewBar CanFocus to false to ensure the host always focused. * Only navigates through TabView if winDialog is not null and ensures TextView being focused. * Fixes both dynamic menu and status bar broken scenarios. * Fix a bug where the subviews oldEnabled can be overridden, even the superview Enable property hasn't changed. * Fixes CanFocus when set to false and HasFocus is true. * Fixes the broken TextView DesiredCursorVisibility. * Prevents TextField being focused by mouse if CanFocus is false. * Fixes the CanFocus on content views. * Fixes #1470. Not all WindowsConsole.InputRecord are caught in WindowsDriver. * Changing the input for a Queue object. * Suppress warnings. * Fixed yet the visibility cursor and adding more unit tests. * Suppressing more warnings.
This commit is contained in:
@@ -457,6 +457,12 @@ namespace Terminal.Gui.Views {
|
||||
Assert.Null (_textField.SelectedText);
|
||||
break;
|
||||
case 9:
|
||||
Assert.Equal (54, _textField.CursorPosition);
|
||||
Assert.Equal (-1, _textField.SelectedStart);
|
||||
Assert.Equal (0, _textField.SelectedLength);
|
||||
Assert.Null (_textField.SelectedText);
|
||||
break;
|
||||
case 10:
|
||||
Assert.Equal (55, _textField.CursorPosition);
|
||||
Assert.Equal (-1, _textField.SelectedStart);
|
||||
Assert.Equal (0, _textField.SelectedLength);
|
||||
@@ -785,5 +791,100 @@ namespace Terminal.Gui.Views {
|
||||
_textField.Paste ();
|
||||
Assert.Equal ("TAB to jump between text fields.", _textField.Text);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitShutdown]
|
||||
public void TextField_SpaceHandling ()
|
||||
{
|
||||
var tf = new TextField () {
|
||||
Width = 10,
|
||||
Text = " "
|
||||
};
|
||||
|
||||
MouseEvent ev = new MouseEvent () {
|
||||
X = 0,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1DoubleClicked,
|
||||
};
|
||||
|
||||
tf.MouseEvent (ev);
|
||||
Assert.Equal (1, tf.SelectedLength);
|
||||
|
||||
ev = new MouseEvent () {
|
||||
X = 1,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1DoubleClicked,
|
||||
};
|
||||
|
||||
tf.MouseEvent (ev);
|
||||
Assert.Equal (1, tf.SelectedLength);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
[InitShutdown]
|
||||
public void CanFocus_False_Wont_Focus_With_Mouse ()
|
||||
{
|
||||
var top = Application.Top;
|
||||
var tf = new TextField () {
|
||||
Width = Dim.Fill (),
|
||||
CanFocus = false,
|
||||
ReadOnly = true,
|
||||
Text = "some text"
|
||||
};
|
||||
var fv = new FrameView ("I shouldn't get focus") {
|
||||
Width = Dim.Fill (),
|
||||
Height = Dim.Fill (),
|
||||
CanFocus = false,
|
||||
};
|
||||
fv.Add (tf);
|
||||
top.Add (fv);
|
||||
|
||||
Application.Begin (top);
|
||||
|
||||
Assert.False (tf.CanFocus);
|
||||
Assert.False (tf.HasFocus);
|
||||
Assert.False (fv.CanFocus);
|
||||
Assert.False (fv.HasFocus);
|
||||
|
||||
tf.MouseEvent (new MouseEvent () {
|
||||
X = 1,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1DoubleClicked
|
||||
});
|
||||
|
||||
Assert.Null (tf.SelectedText);
|
||||
Assert.False (tf.CanFocus);
|
||||
Assert.False (tf.HasFocus);
|
||||
Assert.False (fv.CanFocus);
|
||||
Assert.False (fv.HasFocus);
|
||||
|
||||
Assert.Throws<InvalidOperationException> (() => tf.CanFocus = true);
|
||||
fv.CanFocus = true;
|
||||
tf.CanFocus = true;
|
||||
tf.MouseEvent (new MouseEvent () {
|
||||
X = 1,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1DoubleClicked
|
||||
});
|
||||
|
||||
Assert.Equal ("some ", tf.SelectedText);
|
||||
Assert.True (tf.CanFocus);
|
||||
Assert.True (tf.HasFocus);
|
||||
Assert.True (fv.CanFocus);
|
||||
Assert.True (fv.HasFocus);
|
||||
|
||||
fv.CanFocus = false;
|
||||
tf.MouseEvent (new MouseEvent () {
|
||||
X = 1,
|
||||
Y = 0,
|
||||
Flags = MouseFlags.Button1DoubleClicked
|
||||
});
|
||||
|
||||
Assert.Equal ("some ", tf.SelectedText); // Setting CanFocus to false don't change the SelectedText
|
||||
Assert.False (tf.CanFocus);
|
||||
Assert.False (tf.HasFocus);
|
||||
Assert.False (fv.CanFocus);
|
||||
Assert.False (fv.HasFocus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user