mono / xwt

A cross-platform UI toolkit for creating desktop applications with .NET and Mono
MIT License
1.36k stars 241 forks source link

TreeView: renaming row title #502

Closed bigpcz closed 9 years ago

bigpcz commented 9 years ago

I tried to change the title of a row (TextCellView) to an editable form, but it is not possible to do that for only a row because the DataSource.GetValue returns a String object instead of the TextCellView object.

    protected override void OnKeyPressed(KeyEventArgs args)
    {
        if (args.Key == Key.F2) {
            if (SelectedRow != null) {
                var textCell = (TextCellView)this.DataSource.GetValue(this.SelectedRow, 0);
                textCell.Editable = true;
            }
        }
    }

The intend here is to change the name of the row in the TreeView containing a text column (=renaming action). So the text would change to an editable input, a user would write or change the text and then confirm it by pressing e.g. Return key. The input would change back to non-editable text.

sevoku commented 9 years ago

I assume you mean the text inside a cellview (cells have not "titles"). You mix here some different things. The DataSource contains only the data and not the CellView (which is bound to a column, when you create it). And GetValue returns a string for a DataField correctly.

Xwt allows no direct access to single row CellViews, because they are generated/destroyed dynamically on many platforms. To set the editable state for single rows, you can use the CellView.EditableField property (new TextCellView { EditableField = editableField }) You can find some examples in https://github.com/mono/xwt/blob/master/TestApps/Samples/Samples/ListView2.cs#L34.

sevoku commented 9 years ago

I close this, cause it is not a bug. If you have questions about how Xwt works, or need some help with your implementation, come to the Google group at http://groups.google.com/group/xwt-list

bigpcz commented 9 years ago

Ok. I tried to find a solution for the in-place editing:

in-place-editting

That is not possible currently. It would be nice to just set something like "Editable = true" on the row input widget. It is possible to do that but only for the whole column (every row has editable text input) which is not my concern.

Thanks for the link.