forked from mbk-lab/rui_orig
2
0
Fork 0

bug fixing

This commit is contained in:
Alexei Anoshenko 2022-04-17 11:21:01 +03:00
parent 71993fd8b7
commit 47ca08717d
4 changed files with 30 additions and 10 deletions

View File

@ -538,7 +538,7 @@ For the properties "width", "height", "min-width", "min-height", "max-width", "m
func GetMaxWidth(view View, subviewID string) SizeUnit func GetMaxWidth(view View, subviewID string) SizeUnit
func GetMaxHeight(view View, subviewID string) SizeUnit func GetMaxHeight(view View, subviewID string) SizeUnit
### "margin" и "padding" properties ### "margin" and "padding" properties
The "margin" property determines the outer margins from this View to its neighbors. The "margin" property determines the outer margins from this View to its neighbors.
The "padding" property sets the padding from the border of the View to the content. The "padding" property sets the padding from the border of the View to the content.
@ -621,7 +621,7 @@ equivalent to
view.Set(rui.Margin, rui.Bounds{Top: rui.Px(12), Right: rui.Px(8), Bottom: rui.Px(8), Left: rui.Px(8)}) view.Set(rui.Margin, rui.Bounds{Top: rui.Px(12), Right: rui.Px(8), Bottom: rui.Px(8), Left: rui.Px(8)})
### Свойство "border" ### "border" property
The "border" property defines a border around the View. The frame line is described by three attributes: The "border" property defines a border around the View. The frame line is described by three attributes:
line style, thickness and color. line style, thickness and color.
@ -3136,7 +3136,7 @@ The "checkbox" properties allow you to add a checkbox to each item in the list w
you can select several items in the list. The "checkbox" int property (ItemCheckbox constant) you can select several items in the list. The "checkbox" int property (ItemCheckbox constant)
can take the following values can take the following values
| Value | Constant | Name | Checkbox view | | Value | Constant | Name | Checkbox view |
|:--------:|------------------|------------|----------------------------------------------------| |:--------:|------------------|------------|----------------------------------------------------|
| 0 | NoneCheckbox | "none" | There is no checkbox. Default value | | 0 | NoneCheckbox | "none" | There is no checkbox. Default value |
| 1 | SingleCheckbox | "single" | ◉ A checkbox that allows you to mark only one item | | 1 | SingleCheckbox | "single" | ◉ A checkbox that allows you to mark only one item |

View File

@ -190,6 +190,12 @@ func (imageView *imageViewData) htmlProperties(self View, buffer *strings.Builde
buffer.WriteString(`"`) buffer.WriteString(`"`)
} }
} }
if text := GetImageViewAltText(imageView, ""); text != "" {
buffer.WriteString(` alt="`)
buffer.WriteString(textToJS(text))
buffer.WriteString(`"`)
}
} }
func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) { func (imageView *imageViewData) cssStyle(self View, builder cssBuilder) {

View File

@ -1058,7 +1058,7 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
switch value := adapter.Cell(row, column).(type) { switch value := adapter.Cell(row, column).(type) {
case string: case string:
buffer.WriteString(value) buffer.WriteString(textToJS(value))
case View: case View:
viewHTML(value, buffer) viewHTML(value, buffer)
@ -1071,10 +1071,10 @@ func (table *tableViewData) htmlSubviews(self View, buffer *strings.Builder) {
buffer.WriteString(value.String()) buffer.WriteString(value.String())
case fmt.Stringer: case fmt.Stringer:
buffer.WriteString(value.String()) buffer.WriteString(textToJS(value.String()))
case rune: case rune:
buffer.WriteRune(value) buffer.WriteString(textToJS(string(value)))
case float32: case float32:
buffer.WriteString(fmt.Sprintf("%g", float64(value))) buffer.WriteString(fmt.Sprintf("%g", float64(value)))

View File

@ -123,16 +123,30 @@ func (textView *textViewData) textOverflowUpdated() {
updateCSSProperty(textView.htmlID(), TextOverflow, "", session) updateCSSProperty(textView.htmlID(), TextOverflow, "", session)
} }
func textToJS(text string) string {
for _, ch := range []struct{ old, new string }{
{old: "\\", new: `\\`},
{old: "\"", new: `\"`},
{old: "'", new: `\'`},
{old: "\n", new: `\n`},
{old: "\r", new: `\r`},
{old: "\t", new: `\t`},
{old: "\x00", new: `\x00`},
} {
if strings.Contains(text, ch.old) {
text = strings.ReplaceAll(text, ch.old, ch.new)
}
}
return text
}
func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) { func (textView *textViewData) htmlSubviews(self View, buffer *strings.Builder) {
if value, ok := stringProperty(textView, Text, textView.Session()); ok { if value, ok := stringProperty(textView, Text, textView.Session()); ok {
if !GetNotTranslate(textView, "") { if !GetNotTranslate(textView, "") {
value, _ = textView.session.GetString(value) value, _ = textView.session.GetString(value)
} }
text := strings.ReplaceAll(value, `"`, `\"`) buffer.WriteString(textToJS(value))
text = strings.ReplaceAll(text, "\n", `\n`)
text = strings.ReplaceAll(text, "\r", `\r`)
buffer.WriteString(strings.ReplaceAll(text, `'`, `\'`))
} }
} }