`)
+ viewHTML(value, buffer, "")
+ buffer.WriteString("
")
+ }
}
}
diff --git a/listLayout.go b/listLayout.go
index 9ad7642..a3426b6 100644
--- a/listLayout.go
+++ b/listLayout.go
@@ -163,7 +163,7 @@ func (listLayout *listLayoutData) htmlSubviews(self View, buffer *strings.Builde
if listLayout.views != nil {
for _, view := range listLayout.views {
view.addToCSSStyle(map[string]string{`flex`: `0 0 auto`})
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
}
}
}
diff --git a/listView.go b/listView.go
index d1804e9..7338add 100644
--- a/listView.go
+++ b/listView.go
@@ -659,7 +659,7 @@ func (listView *listViewData) checkboxSubviews(adapter ListAdapter, buffer *stri
if view := listView.getItemView(adapter, i); view != nil {
//view.setNoResizeEvent()
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
} else {
buffer.WriteString("ERROR: invalid item view")
}
@@ -706,7 +706,7 @@ func (listView *listViewData) noneCheckboxSubviews(adapter ListAdapter, buffer *
if view := listView.getItemView(adapter, i); view != nil {
//view.setNoResizeEvent()
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
} else {
buffer.WriteString("ERROR: invalid item view")
}
@@ -737,7 +737,7 @@ func (listView *listViewData) updateCheckboxItem(index int, checked bool) {
if adapter := listView.getAdapter(); adapter != nil {
if view := listView.getItemView(adapter, index); view != nil {
view.setNoResizeEvent()
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
} else {
buffer.WriteString("ERROR: invalid item view")
}
diff --git a/popup.go b/popup.go
index 24af20a..ca963e9 100644
--- a/popup.go
+++ b/popup.go
@@ -720,7 +720,7 @@ func (popup *popupData) Show() {
func (popup *popupData) html(buffer *strings.Builder) {
- viewHTML(popup.layerView, buffer)
+ viewHTML(popup.layerView, buffer, "")
}
func (popup *popupData) viewByHTMLID(id string) View {
diff --git a/resizable.go b/resizable.go
index f9815cb..0860406 100644
--- a/resizable.go
+++ b/resizable.go
@@ -431,6 +431,6 @@ func (resizable *resizableData) htmlSubviews(self View, buffer *strings.Builder)
"grid-row-start": strconv.Itoa(top),
"grid-row-end": strconv.Itoa(top + 1),
})
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
}
}
diff --git a/session.go b/session.go
index 8a8fa52..ff60c2e 100644
--- a/session.go
+++ b/session.go
@@ -329,7 +329,7 @@ func (session *sessionData) writeInitScript(writer *strings.Builder) {
writer.WriteString(`document.getElementById('ruiRootView').innerHTML = '`)
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
- viewHTML(session.rootView, buffer)
+ viewHTML(session.rootView, buffer, "")
text := strings.ReplaceAll(buffer.String(), "'", `\'`)
writer.WriteString(text)
writer.WriteString("';\nscanElementsSize();")
@@ -360,7 +360,7 @@ func (session *sessionData) reload() {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
- viewHTML(session.rootView, buffer)
+ viewHTML(session.rootView, buffer, "")
session.bridge.updateInnerHTML("ruiRootView", buffer.String())
session.bridge.callFunc("scanElementsSize")
}
diff --git a/sessionTheme.go b/sessionTheme.go
index 23e4920..21bb2e7 100644
--- a/sessionTheme.go
+++ b/sessionTheme.go
@@ -339,7 +339,7 @@ func (session *sessionData) SetLanguage(lang string) {
buffer := allocStringBuilder()
defer freeStringBuilder(buffer)
- viewHTML(session.rootView, buffer)
+ viewHTML(session.rootView, buffer, "")
session.bridge.updateInnerHTML("ruiRootView", buffer.String())
}
}
diff --git a/stackLayout.go b/stackLayout.go
index 020b9b1..d35eef5 100644
--- a/stackLayout.go
+++ b/stackLayout.go
@@ -345,7 +345,7 @@ func (layout *stackLayoutData) Push(view View, animation int, onPushFinished fun
buffer.WriteString(`1s ease;">`)
- viewHTML(layout.pushView, buffer)
+ viewHTML(layout.pushView, buffer, "")
buffer.WriteString(``)
session.appendToInnerHTML(htmlID, buffer.String())
@@ -386,7 +386,7 @@ func (layout *stackLayoutData) Pop(animation int, onPopFinished func(View)) bool
buffer.WriteString(`', 'ruiPop', event)" ontransitioncancel="stackTransitionEndEvent('`)
buffer.WriteString(htmlID)
buffer.WriteString(`', 'ruiPop', event)" style="transition: transform 1s ease;">`)
- viewHTML(layout.popView, buffer)
+ viewHTML(layout.popView, buffer, "")
buffer.WriteString(``)
session.appendToInnerHTML(htmlID, buffer.String())
@@ -429,7 +429,7 @@ func (layout *stackLayoutData) htmlSubviews(self View, buffer *strings.Builder)
buffer.WriteString(` style="visibility: hidden;"`)
}
buffer.WriteString(`>`)
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
buffer.WriteString(``)
}
}
diff --git a/tableView.go b/tableView.go
index b9eed8f..ca74885 100644
--- a/tableView.go
+++ b/tableView.go
@@ -1559,7 +1559,7 @@ func (table *tableViewData) writeCellHtml(adapter TableAdapter, row, column int,
buffer.WriteString(value)
case View:
- viewHTML(value, buffer)
+ viewHTML(value, buffer, "")
table.cellViews = append(table.cellViews, value)
case Color:
diff --git a/tabsLayout.go b/tabsLayout.go
index c59f76c..1e00a3e 100644
--- a/tabsLayout.go
+++ b/tabsLayout.go
@@ -861,7 +861,7 @@ func (tabsLayout *tabsLayoutData) htmlSubviews(self View, buffer *strings.Builde
buffer.WriteString(`grid-row-start: 1; grid-row-end: 2; grid-column-start: 1; grid-column-end: 2;">`)
}
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
buffer.WriteString(``)
}
}
diff --git a/view.go b/view.go
index 410de96..b6664a5 100644
--- a/view.go
+++ b/view.go
@@ -836,10 +836,13 @@ func (view *viewData) htmlProperties(self View, buffer *strings.Builder) {
}
}
-func viewHTML(view View, buffer *strings.Builder) {
- viewHTMLTag := view.htmlTag()
+func viewHTML(view View, buffer *strings.Builder, htmlTag string) {
+ if htmlTag == "" {
+ htmlTag = view.htmlTag()
+ }
+ //viewHTMLTag := view.htmlTag()
buffer.WriteRune('<')
- buffer.WriteString(viewHTMLTag)
+ buffer.WriteString(htmlTag)
buffer.WriteString(` id="`)
buffer.WriteString(view.htmlID())
buffer.WriteRune('"')
@@ -907,7 +910,7 @@ func viewHTML(view View, buffer *strings.Builder) {
view.htmlSubviews(view, buffer)
if view.closeHTMLTag() {
buffer.WriteString(``)
- buffer.WriteString(viewHTMLTag)
+ buffer.WriteString(htmlTag)
buffer.WriteRune('>')
}
}
diff --git a/viewUtils.go b/viewUtils.go
index da7a26a..3946d40 100644
--- a/viewUtils.go
+++ b/viewUtils.go
@@ -372,23 +372,7 @@ func GetAccentColor(view View, subviewID ...string) Color {
// GetFontName returns the subview font.
// If the second argument (subviewID) is not specified or it is "" then a value from the first argument (view) is returned.
func GetFontName(view View, subviewID ...string) string {
- if len(subviewID) > 0 && subviewID[0] != "" {
- view = ViewByID(view, subviewID[0])
- }
- if view != nil {
- if font, ok := stringProperty(view, FontName, view.Session()); ok {
- return font
- }
- if value := valueFromStyle(view, FontName); value != nil {
- if font, ok := value.(string); ok {
- return font
- }
- }
- if parent := view.Parent(); parent != nil {
- return GetFontName(parent)
- }
- }
- return ""
+ return stringStyledProperty(view, nil, FontName, true)
}
// GetTextColor returns a text color of the subview.
@@ -725,6 +709,29 @@ func valueFromStyle(view View, tag PropertyName) any {
return getValue(Style)
}
+func stringStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) string {
+ if len(subviewID) > 0 && subviewID[0] != "" {
+ view = ViewByID(view, subviewID[0])
+ }
+ if view != nil {
+ if text, ok := stringProperty(view, tag, view.Session()); ok {
+ return text
+ }
+ if value := valueFromStyle(view, tag); value != nil {
+ if text, ok := value.(string); ok {
+ return text
+ }
+ }
+ if inherit {
+ if parent := view.Parent(); parent != nil {
+ return stringStyledProperty(parent, nil, tag, true)
+ }
+ }
+
+ }
+ return ""
+}
+
func sizeStyledProperty(view View, subviewID []string, tag PropertyName, inherit bool) SizeUnit {
if len(subviewID) > 0 && subviewID[0] != "" {
view = ViewByID(view, subviewID[0])
diff --git a/viewsContainer.go b/viewsContainer.go
index c1dcd3b..7a9bca1 100644
--- a/viewsContainer.go
+++ b/viewsContainer.go
@@ -146,7 +146,7 @@ func (container *viewsContainerData) cssStyle(self View, builder cssBuilder) {
func (container *viewsContainerData) htmlSubviews(self View, buffer *strings.Builder) {
if container.views != nil {
for _, view := range container.views {
- viewHTML(view, buffer)
+ viewHTML(view, buffer, "")
}
}
}