From 7c0449775c15a9e51e16f5ec596de7e1d58db4f6 Mon Sep 17 00:00:00 2001 From: anoshenko Date: Sun, 7 May 2023 19:26:02 +0300 Subject: [PATCH] Bug fixing --- app_scripts.js | 37 ++++++++++++++++++++++++++++++++++++- button.go | 1 + tableView.go | 25 ++++++++++++++++++------- 3 files changed, 55 insertions(+), 8 deletions(-) diff --git a/app_scripts.js b/app_scripts.js index 280977c..173df95 100644 --- a/app_scripts.js +++ b/app_scripts.js @@ -1474,6 +1474,24 @@ function tableViewBlurEvent(element, event) { } } +function setTableCellCursorByID(tableID, row, column) { + var table = document.getElementById(tableID); + if (table) { + if (!setTableCellCursor(table, row, column)) { + const focusStyle = getTableFocusedItemStyle(table); + const oldCellID = table.getAttribute("data-current"); + if (oldCellID) { + const oldCell = document.getElementById(oldCellID); + if (oldCell && oldCell.classList) { + oldCell.classList.remove(focusStyle); + oldCell.classList.remove(getTableSelectedItemStyle(table)); + } + table.removeAttribute("data-current"); + } + } + } +} + function setTableCellCursor(element, row, column) { const cellID = element.id + "-" + row + "-" + column; var cell = document.getElementById(cellID); @@ -1647,6 +1665,24 @@ function tableViewCellKeyDownEvent(element, event) { } } +function setTableRowCursorByID(tableID, row) { + var table = document.getElementById(tableID); + if (table) { + if (!setTableRowCursor(table, row)) { + const focusStyle = getTableFocusedItemStyle(table); + const oldRowID = table.getAttribute("data-current"); + if (oldRowID) { + const oldRow = document.getElementById(oldRowID); + if (oldRow && oldRow.classList) { + oldRow.classList.remove(focusStyle); + oldRow.classList.remove(getTableSelectedItemStyle(table)); + } + table.removeAttribute("data-current"); + } + } + } +} + function setTableRowCursor(element, row) { const tableRowID = element.id + "-" + row; var tableRow = document.getElementById(tableRowID); @@ -1661,7 +1697,6 @@ function setTableRowCursor(element, row) { if (oldRow && oldRow.classList) { oldRow.classList.remove(focusStyle); oldRow.classList.remove(getTableSelectedItemStyle(element)); - } } diff --git a/button.go b/button.go index 6ecb9c8..94c6fd1 100644 --- a/button.go +++ b/button.go @@ -28,6 +28,7 @@ func (button *buttonData) CreateSuperView(session Session) View { HorizontalAlign: CenterAlign, VerticalAlign: CenterAlign, Orientation: StartToEndOrientation, + TabIndex: 0, }) } diff --git a/tableView.go b/tableView.go index 0d935a0..750f9d9 100644 --- a/tableView.go +++ b/tableView.go @@ -524,10 +524,6 @@ func (table *tableViewData) set(tag string, value any) bool { case Current: switch value := value.(type) { - case int: - table.current.Row = value - table.current.Column = -1 - case CellIndex: table.current = value @@ -554,6 +550,7 @@ func (table *tableViewData) set(tag string, value any) bool { table.current.Column = n[1] } else { notCompatibleType(tag, value) + return false } } else { n, err := strconv.Atoi(value) @@ -566,8 +563,13 @@ func (table *tableViewData) set(tag string, value any) bool { } default: - notCompatibleType(tag, value) - return false + if n, ok := isInt(value); ok { + table.current.Row = n + table.current.Column = -1 + } else { + notCompatibleType(tag, value) + return false + } } default: @@ -585,9 +587,18 @@ func (table *tableViewData) propertyChanged(tag string) { CellBorder, HeadHeight, HeadStyle, FootHeight, FootStyle, CellPaddingTop, CellPaddingRight, CellPaddingBottom, CellPaddingLeft, TableCellClickedEvent, TableCellSelectedEvent, TableRowClickedEvent, - TableRowSelectedEvent, AllowSelection, Current: + TableRowSelectedEvent, AllowSelection: table.ReloadTableData() + case Current: + switch GetTableSelectionMode(table) { + case CellSelection: + table.session.callFunc("setTableCellCursorByID", table.htmlID(), table.current.Row, table.current.Column) + + case RowSelection: + table.session.callFunc("setTableRowCursorByID", table.htmlID(), table.current.Row) + } + case Gap: htmlID := table.htmlID() session := table.Session()