public override void KeyDown(NSEvent theEvent)
        {
            base.KeyDown(theEvent);


            if (KeyDefinder.SpaceKey(theEvent))
            {
                if (SelectedRowCount != 1)
                {
                    return;
                }

                var indexSelectedRow = SelectedRow;

                //var rowView = GetRowView(SelectedRow, false);
                var cellView = GetView(0, indexSelectedRow, false);

                foreach (var view in cellView.Subviews)
                {
                    if (view is NSButton)
                    {
                        var ckb = (NSButton)view;
                        ckb.PerformClick(ckb);
                    }
                }
            }
        }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            InitTableCell();

            InitTable();

            btn_copyCell.Title = "Copy clicked cell value";
            btn_copyRow.Title  = "Copy selected row";

            btn_updateRow.Title    = "Update row";
            btn_updateColumn.Title = "Update column";

            btn_addRow.Title = "Add row";

            tf_row.PlaceholderString    = "RowIndex";
            tf_column.PlaceholderString = "C0";

            tbl.Activated += (sender, e) => {
                var ds = (TableDataSource)tbl.DataSource;

                var tableRow      = ds.Data[(int)tbl.ClickedRow];
                var clickedColumn = tbl.TableColumns()[(int)tbl.ClickedColumn];

                var cellValue = tableRow.GetValue(clickedColumn.Identifier).Text;
                _cellValue = cellValue;
            };

            btn_copyCell.Activated += (sender, e) =>
                                      _clipboard.CopyString(_cellValue);

            btn_copyRow.Activated += (sender, e) => {
                if (tbl.SelectedRow == -1)
                {
                    return;
                }

                var ds       = (TableDataSource)tbl.DataSource;
                var tableRow = ds.Data[(int)tbl.SelectedRow];

                var rowValue = string.Empty;
                foreach (var column in tbl.TableColumns())
                {
                    if (!string.IsNullOrEmpty(rowValue))
                    {
                        rowValue += "\t";
                    }

                    rowValue += tableRow.GetValue(column.Identifier).Text;
                }

                _clipboard.CopyString(rowValue);
            };


            btn_updateRow.Activated += (sender, e) => {
                if (int.TryParse(tf_row.StringValue, out int rowIndex))
                {
                    var ds = (TableDataSource)tbl.DataSource;

                    if (ds.Data.Count > rowIndex &&
                        rowIndex >= 0)
                    {
                        var tableRow = (SimpleTableRow)ds.Data[rowIndex];

                        var rand = new Random();
                        var min  = 0;
                        var max  = 900;

                        foreach (var column in tbl.TableColumns())
                        {
                            tableRow.DataCell[column.Identifier] =
                                nameof(SimpleTableRow) + " " + rand.Next(min, max);
                        }

                        var rowIndexSet = new NSIndexSet(rowIndex);

                        var columnIndexSet = new NSMutableIndexSet();
                        for (int i = 0; i < tbl.TableColumns().Length; i++)
                        {
                            columnIndexSet.Add(new NSIndexSet(i));
                        }

                        tbl.ReloadData(rowIndexSet, columnIndexSet);
                    }
                }
            };

            btn_updateColumn.Activated += (sender, e) => {
                var foundColumnIndex = tbl.FindColumn((NSString)tf_column.StringValue);

                if (foundColumnIndex < 0)
                {
                    return;
                }

                var column = tbl.TableColumns()[foundColumnIndex];

                var ds = (TableDataSource)tbl.DataSource;

                var rand = new Random();
                var min  = 0;
                var max  = 900;

                foreach (var row in ds.Data)
                {
                    var tableRow = (SimpleTableRow)row;
                    tableRow.DataCell[column.Identifier] =
                        nameof(SimpleTableRow) + " " + rand.Next(min, max);
                }

                var columnIndexSet = new NSIndexSet(foundColumnIndex);

                var rowIndexSet = new NSMutableIndexSet();
                for (int i = 0; i < ds.Data.Count; i++)
                {
                    rowIndexSet.Add(new NSIndexSet(i));
                }

                tbl.ReloadData(rowIndexSet, columnIndexSet);
            };

            btn_addRow.Activated += (sender, e) => {
                var tableRow = new SimpleTableRow();
                foreach (var column in tbl.TableColumns())
                {
                    tableRow.DataCell.Add(column.Identifier, column.Identifier);
                }

                var ds = (TableDataSource)tbl.DataSource;
                ds.AddRow(tableRow);
            };

            //ordinary table
            var ordinaryTbl = (BaseOrdinaryTable)tbl;

            ordinaryTbl.SelectedRowIsChanged += (sender, e) =>
                                                Console.WriteLine("Selected row is changed");

            ordinaryTbl.WasKeyDown += (sender, e) => {
                var theEvent = (NSEvent)sender;
                Console.WriteLine("key code of pressed key: " + theEvent.KeyCode);

                if (KeyDefinder.SpaceKey(theEvent))
                {
                    Console.WriteLine("Space key was pressed");
                }
            };
        }