Bug fixing

This commit is contained in:
anoshenko 2023-05-07 19:26:02 +03:00
parent 4ec3fe2ff2
commit 7c0449775c
3 changed files with 55 additions and 8 deletions

View File

@ -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));
}
}

View File

@ -28,6 +28,7 @@ func (button *buttonData) CreateSuperView(session Session) View {
HorizontalAlign: CenterAlign,
VerticalAlign: CenterAlign,
Orientation: StartToEndOrientation,
TabIndex: 0,
})
}

View File

@ -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()