Skip to content

[v1] Best solution to enable (un)check item on TreeView with mouse ? #3896

Answered by tznind
lzanoni-stm asked this question in Q&A
Discussion options

You must be logged in to vote

If you are stuck using v1 then you can use reflection, here is an example for how to detect click in the first Rune after the branch lines of tree:

using System.Reflection;
using Terminal.Gui;
using Terminal.Gui.Trees;

Application.Init();

Application.Run(new MyViewYay());

Application.Shutdown();

class MyViewYay : Window
{
    private readonly TreeView _tv;

    public MyViewYay()
    {
        _tv = new TreeView()
        {
            Width = Dim.Fill(),
            Height = Dim.Fill()
        };
        _tv.AddObject(new TreeNode("Hello"));

        _tv.MouseClick += Tv_MouseClick;
        Add(_tv);
    }

    private void Tv_MouseClick(MouseEventArgs obj)
    {
        var ht = Get…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@lzanoni-stm
Comment options

Answer selected by lzanoni-stm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants