Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problems with TreeGridView.SelectedItem #52

Closed
evgeny-k opened this issue Aug 23, 2012 · 2 comments
Closed

Problems with TreeGridView.SelectedItem #52

evgeny-k opened this issue Aug 23, 2012 · 2 comments

Comments

@evgeny-k
Copy link

  1. start testcase, collapse [2]Name20 item. press button. [3]Name202 will be shown but without selection mark
  2. I think, that when parent is collapsed, it should be set as selected (Windows has the same behavior)

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Eto;
using Eto.IO;
using Eto.Forms;
using Eto.Drawing;
using System.Threading;

namespace etotest
{
class Program
{
[STAThread]
static void Main(string[] args)
{
Generator generator;
if (EtoEnvironment.Platform.IsWindows)
{
generator = Generator.GetGenerator("Eto.Platform.Wpf.Generator, Eto.Platform.Wpf");
}
else if (EtoEnvironment.Platform.IsMac)
{
generator = Generator.GetGenerator("Eto.Platform.Mac.Generator, Eto.Platform.Mac");
}
else
{
generator = Generator.GetGenerator("Eto.Platform.GtkSharp.Generator, Eto.Platform.Gtk");
}

        var app = new TestApplication(generator);
        app.Run(args);
    }
}

public class TestApplication : Application
{
    public TestApplication(Generator generator)
        : base(generator)
    {
        this.Name = "Test Application";
    }

    public override void OnInitialized(EventArgs e)
    {
        this.MainForm = new MainForm();
        HandleEvent(Application.TerminatingEvent);

        base.OnInitialized(e);

        // show the main form
        this.MainForm.Show();
    }

}

public class MyTreeGridItem : TreeGridItem
{
    public Icon MyImage { get; set; }
    public String MyCaption { get; set; }

}

public class MainForm : Form
{
    int[] arr = new int[] { 5, 5, 5 };
    TreeGridView tv;
    TreeGridItem it;
    Icon ic;


    void CreateItem(TreeGridItem aParent, string aBaseName, int aLevel)
    {
        var lName = "[" + aLevel + "]" + aBaseName;
        var lItem = new MyTreeGridItem { MyImage = ic, MyCaption = lName };
        lItem.Expanded = aLevel == 0;
        if (lName == "[3]Name202") { it = lItem; };
        aParent.Children.Add(lItem);
        if (aLevel < arr.Length)
            for (int i = 0; i < arr[aLevel]; i++)
                CreateItem(lItem, aBaseName + i.ToString(), aLevel + 1);
    }


    void CreateTree()
    {
        TreeGridItem lRoot = new TreeGridItem();
        CreateItem(lRoot, "Name", 0);
        lRoot.Expanded = true;

        Application.Instance.Invoke(delegate
        {
            tv.DataStore = lRoot;
        });
    }

    public MainForm()
    {
        // black.ico is added into project as "Embedded resource"
        ic = Icon.FromResource("DocsEditor.black.ico");
        Size = new Size(500, 600);
        var fMainSplitter = new Splitter { Orientation = SplitterOrientation.Horizontal, FixedPanel = SplitterFixedPanel.Panel1 };
        this.AddDockedControl(fMainSplitter, new Padding(5));
        fMainSplitter.Panel1 = new Panel();
        var lPanelLayout = new TableLayout(fMainSplitter.Panel1 as Panel, 1, 1);
        lPanelLayout.Padding = new Padding(0);

        tv = new TreeGridView();
        tv.Columns.Add(new GridColumn { DataCell = new ImageTextCell("MyImage", "MyCaption") });
        lPanelLayout.Add(tv, 0, 0, true, true);

        fMainSplitter.Panel2 = new Panel();
        lPanelLayout = new TableLayout(fMainSplitter.Panel2 as Panel, 1, 1);
        lPanelLayout.Padding = new Padding(0);
        var btn = new Button { Text = "Set SelectedItem" };
        lPanelLayout.Add(btn, 0, 0, false, false);
        btn.Click += (sender, e) => { tv.SelectedItem = it; };

        fMainSplitter.Position = 250;
        CreateTree();
        tv.SelectedItem = it;
    }
}

}

@cwensley
Copy link
Member

I can't reproduce #1 - It does have a selection mark in all platforms - though in WPF it is a very light grey since the control is not focussed..

@evgeny-k
Copy link
Author

reviewed steps (WPF):
start testcase,
a)select [3]Name204, collapse collapse [2]Name20 item. press button. [3]Name202 Item is selected with usual mark!
b)collapse again [2]Name20 item. press button. [3]Name202 will be shown but without selection mark.
as for me this is bug because in (a) item is selected with usual mark,
in case item was already selected and after re-selecting it (or expanding parent), it loses usual mark

http://screencast.com/t/56dG6IdU5P

reviewed steps (mac):
collapse [2]Name20 item and expand it again. selection mark from [3]Name202 was disappeared

as a workaround for this I suggest (2) i.e. when selected item became invisible, (it's parent was collapsed), nearest visible parent should be set as selected

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants