From 655bea09a823ba3c3d91d8b6498bfecf0f72cc3c Mon Sep 17 00:00:00 2001 From: Alexei Anoshenko Date: Fri, 28 Aug 2026 18:54:47 +0300 Subject: [PATCH] Added ReloadListViewItem method to ListView interface --- CHANGELOG.md | 3 ++- listView.go | 38 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 38 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a8f115b..2149827 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,9 +3,10 @@ * Removed "style-disabled" property and GetDisabledStyle function * Added GoogleFonts field to AppParams * Added functions: GetWhiteSpace, GetWordBreak, ScrollIntoViewIfNeeded, GetBackgroundColorPair, -GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair +GetAccentColorPair, GetTextColorPair, GetTextLineColor, GetCaretColorPair, GetColumnSeparatorColorPair, ReloadListViewItem * Added ClientSession interface * Added ClientSession, Popups, PopupDefault, PopupDefaultsSeq, and SetPopupDefaults methods to Session interface +* Added ReloadListViewItem method to ListView interface * Removed ClientItem, SetClientItem, RemoveClientItem, and RemoveAllClientItems methods from Session interface * Added DismissWithoutAnimation add SetHotKey methods to Popup interface * Added "outside-color" add "outside-filter" properties to Popup interface diff --git a/listView.go b/listView.go index 6fffeac..117c4b5 100644 --- a/listView.go +++ b/listView.go @@ -121,9 +121,13 @@ const ( type ListView interface { View ParentView + // ReloadListViewData updates ListView content ReloadListViewData() + // ReloadListViewItem updates the contents of the item at the given index. + ReloadListViewItem(index int) + getItemFrames() []Frame } @@ -445,9 +449,8 @@ func (listView *listViewData) getAdapter() ListAdapter { } func (listView *listViewData) ReloadListViewData() { - itemCount := 0 if adapter := listView.getAdapter(); adapter != nil { - itemCount = adapter.ListSize() + itemCount := adapter.ListSize() if itemCount != len(listView.items) { listView.items = make([]View, itemCount) @@ -465,6 +468,25 @@ func (listView *listViewData) ReloadListViewData() { updateInnerHTML(listView.htmlID(), listView.session) } +func (listView *listViewData) ReloadListViewItem(index int) { + adapter := listView.getAdapter() + if adapter == nil || index < 0 || index >= adapter.ListSize() || index >= len(listView.items) { + return + } + + listView.items[index] = adapter.ListItem(index, listView.Session()) + + if view := listView.items[index]; view != nil { + html := allocStringBuilder() + defer freeStringBuilder(html) + + listView.session.callFunc("hideTooltip") + + viewHTML(view, html, "") + listView.session.updateInnerHTML(listView.htmlID()+"-"+strconv.Itoa(index), html.String()) + } +} + func (listView *listViewData) getItemFrames() []Frame { return listView.itemFrame } @@ -1281,6 +1303,7 @@ func GetListViewAdapter(view View, subviewID ...string) ListAdapter { } // ReloadListViewData updates ListView content +// // If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated. func ReloadListViewData(view View, subviewID ...string) { if view = getSubview(view, subviewID); view != nil { @@ -1289,3 +1312,14 @@ func ReloadListViewData(view View, subviewID ...string) { } } } + +// ReloadListViewItem updates updates the contents of the ListView item at the given index. +// +// If the second argument (subviewID) is not specified or it is "" then content the first argument (view) is updated. +func ReloadListViewItem(index int, view View, subviewID ...string) { + if view = getSubview(view, subviewID); view != nil { + if listView, ok := view.(ListView); ok { + listView.ReloadListViewItem(index) + } + } +}