Trying to directly control caret/cursor visibility for my custom derived View. #4186
Answered
by
tznind
sillycowvalley
asked this question in
Q&A
|
I'm building my own edit control (of sorts) and would like the cursor to be visible when my control HasFocus. I read this (and can see this may change): The only condition I don't seem to be able to set (or understand how to) is (my Thanks. |
Answered by
tznind
Jul 4, 2025
Replies: 2 comments
|
Ok here is how to do it. Note that I am using class MyView : View
{
public MyView ()
{
CanFocus = true;
CursorVisibility = CursorVisibility.Default;
}
/// <inheritdoc />
public override Point? PositionCursor ()
{
return new Point (1,1);
}
}
private static int Main (string [] args)
{
Application.Init (null,"v2");
var w = new Toplevel();
w.Add (new TextField (){Text = "Hi", Width = 5, Height = 1});
w.Add (new MyView ()
{
Y = 1,
Width = 5,
Height = 5,
Text = "Hhh"
});
Application.Run (w);
Application.Shutdown ();
return 0;
} |
0 replies
Answer selected by
sillycowvalley
|
Perfect! Thank you. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Ok here is how to do it. Note that I am using
"v2"for the driver, when I leave it blank (WindowsDriver i.e. v1) then the cursor keeps vanishing even in the TextField.