diff --git a/Terminal.Gui/View/ViewSubViews.cs b/Terminal.Gui/View/ViewSubViews.cs
index 69148565e..2d84bfd45 100644
--- a/Terminal.Gui/View/ViewSubViews.cs
+++ b/Terminal.Gui/View/ViewSubViews.cs
@@ -31,14 +31,14 @@ public partial class View
/// Adds a subview (child) to this view.
///
- ///
- /// The Views that have been added to this view can be retrieved via the property. See also
- ///
- ///
- ///
- /// Subviews will be disposed when this View is disposed. In other-words, calling this method causes
- /// the lifecycle of the subviews to be transferred to this View.
- ///
+ ///
+ /// The Views that have been added to this view can be retrieved via the property. See also
+ ///
+ ///
+ ///
+ /// Subviews will be disposed when this View is disposed. In other-words, calling this method causes
+ /// the lifecycle of the subviews to be transferred to this View.
+ ///
///
public virtual void Add (View view)
{
@@ -49,12 +49,12 @@ public partial class View
if (_subviews is null)
{
- _subviews = new List ();
+ _subviews = new ();
}
if (_tabIndexes is null)
{
- _tabIndexes = new List ();
+ _tabIndexes = new ();
}
_subviews.Add (view);
@@ -83,7 +83,7 @@ public partial class View
view.Enabled = false;
}
- OnAdded (new SuperViewChangedEventArgs (this, view));
+ OnAdded (new (this, view));
if (IsInitialized && !view.IsInitialized)
{
@@ -99,14 +99,14 @@ public partial class View
/// Adds the specified views (children) to the view.
/// Array of one or more views (can be optional parameter).
///
- ///
- /// The Views that have been added to this view can be retrieved via the property. See also
- /// and .
- ///
- ///
- /// Subviews will be disposed when this View is disposed. In other-words, calling this method causes
- /// the lifecycle of the subviews to be transferred to this View.
- ///
+ ///
+ /// The Views that have been added to this view can be retrieved via the property. See also
+ /// and .
+ ///
+ ///
+ /// Subviews will be disposed when this View is disposed. In other-words, calling this method causes
+ /// the lifecycle of the subviews to be transferred to this View.
+ ///
///
public void Add (params View [] views)
{
@@ -199,10 +199,11 @@ public partial class View
/// Removes a subview added via or from this View.
///
- ///
- /// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the Subview's
- /// lifecycle to be transferred to the caller; the caller muse call .
- ///
+ ///
+ /// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
+ /// Subview's
+ /// lifecycle to be transferred to the caller; the caller muse call .
+ ///
///
public virtual void Remove (View view)
{
@@ -227,7 +228,7 @@ public partial class View
}
}
- OnRemoved (new SuperViewChangedEventArgs (this, view));
+ OnRemoved (new (this, view));
if (Focused == view)
{
@@ -236,13 +237,15 @@ public partial class View
}
///
- /// Removes all subviews (children) added via or from this View.
+ /// Removes all subviews (children) added via or from this View.
///
///
- ///
- /// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the Subview's
- /// lifecycle to be transferred to the caller; the caller must call on any Views that were added.
- ///
+ ///
+ /// Normally Subviews will be disposed when this View is disposed. Removing a Subview causes ownership of the
+ /// Subview's
+ /// lifecycle to be transferred to the caller; the caller must call on any Views that were
+ /// added.
+ ///
///
public virtual void RemoveAll ()
{
@@ -379,7 +382,6 @@ public partial class View
}
}
-
/// Event fired when the value is being changed.
public event EventHandler CanFocusChanged;
@@ -498,7 +500,6 @@ public partial class View
return false;
}
-
/// Method invoked when a view loses focus.
/// The view that is getting focus.
/// true, if the event was handled, false otherwise.
@@ -855,36 +856,31 @@ public partial class View
/// Positions the cursor in the right position based on the currently focused view in the chain.
///
///
- /// Views that are focusable and want the cursor visible should override
- /// place the cursor in a location that makes sense. Unix terminals do not have
- /// a way of hiding the cursor, so it can be distracting to have the cursor left at
- /// the last focused view. Views should make sure that they place the cursor
- /// in a visually sensible place.
+ ///
+ /// Views that are focusable and want the cursor visible should override ,
+ /// use to place the cursor in a location that makes sense, use
+ ///
+ /// to make the cursor visible, and return the position where the cursor was placed.
+ ///
+ ///
+ /// Unix terminals do not have a way of hiding the cursor, so it can be distracting to have the cursor left at
+ /// the last focused view. Views should make sure that they place the cursor in a visually sensible place.
+ ///
///
- /// Viewport-relative cursor position.
+ /// Viewport-relative cursor position. Return to ensure the cursor is not visible.
public virtual Point? PositionCursor ()
{
- //if (!IsInitialized)
- //{
- // return null;
- //}
-
- //// TODO: v2 - This needs to support Subviews of Adornments too
-
- //// By default we will position the cursor at the top left corner of the Viewport.
- //// Overrides should return the position where the cursor has been placed.
- //Point location = Viewport.Location;
-
- //if (CanFocus && HasFocus && ContentSize != Size.Empty)
- //{
- // location.X = TextFormatter.HotKeyPos == -1 ? 0 : TextFormatter.CursorPosition;
- // location.Y = 0;
- // Move (location.X, location.Y);
- // return location;
- //}
+ if (CanFocus && HasFocus && ContentSize.HasValue)
+ {
+ // Base class will position the cursor at the end of the text.
+ Point location = Viewport.Location;
+ location.X = TextFormatter.HotKeyPos == -1 ? 0 : TextFormatter.CursorPosition;
+ location.Y = 0;
+ Move (location.X, location.Y);
+ }
+ // Returning null will hide the cursor.
return null;
-
}
#endregion Focus
diff --git a/Terminal.Gui/Views/TextField.cs b/Terminal.Gui/Views/TextField.cs
index 0071dad46..423fa2be5 100644
--- a/Terminal.Gui/Views/TextField.cs
+++ b/Terminal.Gui/Views/TextField.cs
@@ -756,11 +756,11 @@ public class TextField : View
{
foreach (char ch in toAdd)
{
- KeyCode key;
+ Key key;
try
{
- key = (KeyCode)ch;
+ key = ch;
}
catch (Exception)
{
@@ -769,7 +769,7 @@ public class TextField : View
);
}
- InsertText (new Key { KeyCode = key }, useOldCursorPos);
+ InsertText (key, useOldCursorPos);
}
}
@@ -819,7 +819,7 @@ public class TextField : View
}
///
- protected internal override bool OnMouseEvent (MouseEvent ev)
+ protected internal override bool OnMouseEvent (MouseEvent ev)
{
if (!ev.Flags.HasFlag (MouseFlags.Button1Pressed)
&& !ev.Flags.HasFlag (MouseFlags.ReportMousePosition)
@@ -1026,7 +1026,7 @@ public class TextField : View
Driver.AddRune ((Rune)' ');
}
- //PositionCursor ();
+ PositionCursor ();
RenderCaption ();
@@ -1035,16 +1035,16 @@ public class TextField : View
_isDrawing = false;
}
- ///
- public override bool OnEnter (View view)
- {
- if (IsInitialized)
- {
- Application.Driver.SetCursorVisibility (CursorVisibility.Default);
- }
+ /////
+ //public override bool OnEnter (View view)
+ //{
+ // if (IsInitialized)
+ // {
+ // Application.Driver.SetCursorVisibility (CursorVisibility.Default);
+ // }
- return base.OnEnter (view);
- }
+ // return base.OnEnter (view);
+ //}
///
public override bool? OnInvokingKeyBindings (Key a)
@@ -1269,7 +1269,7 @@ public class TextField : View
}
else
{
- //PositionCursor ();
+ PositionCursor ();
}
}
diff --git a/Terminal.Gui/Views/TextView.cs b/Terminal.Gui/Views/TextView.cs
index 7c4de16df..a83be01a3 100644
--- a/Terminal.Gui/Views/TextView.cs
+++ b/Terminal.Gui/Views/TextView.cs
@@ -3228,7 +3228,7 @@ public class TextView : View
}
else
{
- //PositionCursor ();
+ PositionCursor ();
}
}
}
@@ -3353,7 +3353,7 @@ public class TextView : View
if (Used)
{
- //PositionCursor ();
+ PositionCursor ();
}
else
{
@@ -3390,7 +3390,7 @@ public class TextView : View
else if (ev.Flags.HasFlag (MouseFlags.Button1Pressed | MouseFlags.ReportMousePosition))
{
ProcessMouseClick (ev, out List line);
- //PositionCursor ();
+ PositionCursor ();
if (_model.Count > 0 && _shiftSelecting && Selecting)
{
@@ -3441,7 +3441,7 @@ public class TextView : View
}
ProcessMouseClick (ev, out _);
- //PositionCursor ();
+ PositionCursor ();
_lastWasKill = false;
_columnTrack = CurrentColumn;
}
@@ -3454,7 +3454,7 @@ public class TextView : View
}
ProcessMouseClick (ev, out _);
- // PositionCursor ();
+ PositionCursor ();
if (!Selecting)
{
@@ -3514,7 +3514,7 @@ public class TextView : View
CurrentColumn = CurrentRow == newPos.Value.row ? newPos.Value.col : line.Count;
}
- // PositionCursor ();
+ PositionCursor ();
_lastWasKill = false;
_columnTrack = CurrentColumn;
}
@@ -3534,7 +3534,7 @@ public class TextView : View
}
CurrentColumn = line.Count;
- //PositionCursor ();
+ PositionCursor ();
_lastWasKill = false;
_columnTrack = CurrentColumn;
}
@@ -3554,7 +3554,7 @@ public class TextView : View
List line = GetCurrentLine ();
CurrentColumn = line.Count;
TrackColumn ();
- //PositionCursor ();
+ PositionCursor ();
}
/// Will scroll the to the first line and position the cursor there.
@@ -3565,7 +3565,7 @@ public class TextView : View
CurrentColumn = 0;
_leftColumn = 0;
TrackColumn ();
- //PositionCursor ();
+ PositionCursor ();
SetNeedsDisplay ();
}
@@ -3671,7 +3671,7 @@ public class TextView : View
ClearRegion (viewport.Left, row, right, bottom);
}
- //PositionCursor ();
+ PositionCursor ();
_isDrawing = false;
}
@@ -4174,7 +4174,7 @@ public class TextView : View
}
else
{
- //PositionCursor ();
+ PositionCursor ();
}
OnUnwrappedCursorPosition ();
@@ -4525,7 +4525,7 @@ public class TextView : View
}
else
{
- //PositionCursor ();
+ PositionCursor ();
}
}
@@ -5357,7 +5357,7 @@ public class TextView : View
}
TrackColumn ();
- //PositionCursor ();
+ PositionCursor ();
}
else if (CurrentRow > Frame.Height)
{
@@ -5436,7 +5436,7 @@ public class TextView : View
}
TrackColumn ();
- //PositionCursor ();
+ PositionCursor ();
}
DoNeededAction ();
@@ -5462,7 +5462,7 @@ public class TextView : View
}
TrackColumn ();
- // PositionCursor ();
+ PositionCursor ();
}
DoNeededAction ();
@@ -5555,7 +5555,7 @@ public class TextView : View
}
TrackColumn ();
- //PositionCursor ();
+ PositionCursor ();
}
DoNeededAction ();
diff --git a/Terminal.Gui/Views/TileView.cs b/Terminal.Gui/Views/TileView.cs
index 315fdabfb..fe964f06d 100644
--- a/Terminal.Gui/Views/TileView.cs
+++ b/Terminal.Gui/Views/TileView.cs
@@ -979,13 +979,13 @@ public class TileView : View
DrawSplitterSymbol ();
}
- public override bool OnEnter (View view)
- {
- Driver.SetCursorVisibility (CursorVisibility.Default);
- PositionCursor ();
+ //public override bool OnEnter (View view)
+ //{
+ // Driver.SetCursorVisibility (CursorVisibility.Default);
+ // PositionCursor ();
- return base.OnEnter (view);
- }
+ // return base.OnEnter (view);
+ //}
public override Point? PositionCursor ()
{
diff --git a/Terminal.Gui/Views/TreeView/TreeView.cs b/Terminal.Gui/Views/TreeView/TreeView.cs
index fa59b277d..31e3b59b3 100644
--- a/Terminal.Gui/Views/TreeView/TreeView.cs
+++ b/Terminal.Gui/Views/TreeView/TreeView.cs
@@ -468,7 +468,7 @@ public class TreeView : View, ITreeView where T : class
// TODO: Should this be cancelable?
ObjectActivatedEventArgs e = new (this, o);
OnObjectActivated (e);
- PositionCursor ();
+ //PositionCursor ();
return true;
}
return false;
@@ -676,7 +676,7 @@ public class TreeView : View, ITreeView where T : class
var characterAsStr = character.ToString ();
AdjustSelectionToNext (b => AspectGetter (b.Model).StartsWith (characterAsStr, caseSensitivity));
- PositionCursor ();
+ //PositionCursor ();
}
///
@@ -1231,7 +1231,7 @@ public class TreeView : View, ITreeView where T : class
{
if (IsInitialized)
{
- PositionCursor ();
+ //PositionCursor ();
}
}
@@ -1250,6 +1250,7 @@ public class TreeView : View, ITreeView where T : class
if (idx - ScrollOffsetVertical >= 0 && idx - ScrollOffsetVertical < Viewport.Height)
{
Move (0, idx - ScrollOffsetVertical);
+ Application.Driver.SetCursorVisibility (DesiredCursorVisibility);
return null;//new Point (0, idx - ScrollOffsetVertical);
}