forked from mbk-lab/rui_orig
bug fixing
This commit is contained in:
parent
3097f89f5a
commit
fcea1c89a3
|
@ -538,7 +538,7 @@ func (edit *editViewData) handleCommand(self View, command string, data DataObje
|
||||||
return edit.viewData.handleCommand(self, command, data)
|
return edit.viewData.handleCommand(self, command, data)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetText returns a text of the subview.
|
// GetText returns a text of the EditView subview.
|
||||||
// If the second argument (subviewID) is "" then a text of the first argument (view) is returned.
|
// If the second argument (subviewID) is "" then a text of the first argument (view) is returned.
|
||||||
func GetText(view View, subviewID string) string {
|
func GetText(view View, subviewID string) string {
|
||||||
if subviewID != "" {
|
if subviewID != "" {
|
||||||
|
|
11
imageView.go
11
imageView.go
|
@ -266,9 +266,18 @@ func GetImageViewSource(view View, subviewID string) string {
|
||||||
// GetImageViewAltText returns an alternative text description of an ImageView subview.
|
// GetImageViewAltText returns an alternative text description of an ImageView subview.
|
||||||
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
// If the second argument (subviewID) is "" then a left position of the first argument (view) is returned
|
||||||
func GetImageViewAltText(view View, subviewID string) string {
|
func GetImageViewAltText(view View, subviewID string) string {
|
||||||
if text, ok := stringProperty(view, AltText, view.Session()); ok {
|
if subviewID != "" {
|
||||||
|
view = ViewByID(view, subviewID)
|
||||||
|
}
|
||||||
|
|
||||||
|
if view != nil {
|
||||||
|
if value := view.getRaw(AltText); value != nil {
|
||||||
|
if text, ok := value.(string); ok {
|
||||||
|
text, _ = view.Session().GetString(text)
|
||||||
return text
|
return text
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -264,6 +264,7 @@ func (session *sessionData) setContent(content SessionContent, self Session) boo
|
||||||
session.content = content
|
session.content = content
|
||||||
session.rootView = content.CreateRootView(self)
|
session.rootView = content.CreateRootView(self)
|
||||||
if session.rootView != nil {
|
if session.rootView != nil {
|
||||||
|
session.rootView.setParentID("ruiRootView")
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,13 @@ func updateCSSStyle(htmlID string, session Session) {
|
||||||
|
|
||||||
func updateInnerHTML(htmlID string, session Session) {
|
func updateInnerHTML(htmlID string, session Session) {
|
||||||
if !session.ignoreViewUpdates() {
|
if !session.ignoreViewUpdates() {
|
||||||
if view := session.viewByHTMLID(htmlID); view != nil {
|
var view View
|
||||||
|
if htmlID == "ruiRootView" {
|
||||||
|
view = session.RootView()
|
||||||
|
} else {
|
||||||
|
view = session.viewByHTMLID(htmlID)
|
||||||
|
}
|
||||||
|
if view != nil {
|
||||||
script := allocStringBuilder()
|
script := allocStringBuilder()
|
||||||
defer freeStringBuilder(script)
|
defer freeStringBuilder(script)
|
||||||
|
|
||||||
|
|
|
@ -214,6 +214,11 @@ func (tabsLayout *tabsLayoutData) set(tag string, value interface{}) bool {
|
||||||
tabsLayout.tabCloseListener = listeners
|
tabsLayout.tabCloseListener = listeners
|
||||||
|
|
||||||
case Current:
|
case Current:
|
||||||
|
if current, ok := value.(int); ok && current < 0 {
|
||||||
|
tabsLayout.remove(Current)
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
oldCurrent := tabsLayout.currentItem()
|
oldCurrent := tabsLayout.currentItem()
|
||||||
if !tabsLayout.setIntProperty(Current, value) {
|
if !tabsLayout.setIntProperty(Current, value) {
|
||||||
return false
|
return false
|
||||||
|
@ -611,7 +616,6 @@ func (tabsLayout *tabsLayoutData) Append(view View) {
|
||||||
}
|
}
|
||||||
defer tabsLayout.propertyChangedEvent(Current)
|
defer tabsLayout.propertyChangedEvent(Current)
|
||||||
}
|
}
|
||||||
updateInnerHTML(tabsLayout.htmlID(), tabsLayout.session)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -621,7 +625,7 @@ func (tabsLayout *tabsLayoutData) Insert(view View, index int) {
|
||||||
tabsLayout.views = []View{}
|
tabsLayout.views = []View{}
|
||||||
}
|
}
|
||||||
if view != nil {
|
if view != nil {
|
||||||
if current := tabsLayout.currentItem(); current >= int(index) {
|
if current := tabsLayout.currentItem(); current >= index {
|
||||||
tabsLayout.properties[Current] = current + 1
|
tabsLayout.properties[Current] = current + 1
|
||||||
defer tabsLayout.propertyChangedEvent(Current)
|
defer tabsLayout.propertyChangedEvent(Current)
|
||||||
}
|
}
|
||||||
|
@ -638,40 +642,46 @@ func (tabsLayout *tabsLayoutData) RemoveView(index int) View {
|
||||||
tabsLayout.views = []View{}
|
tabsLayout.views = []View{}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
i := int(index)
|
|
||||||
count := len(tabsLayout.views)
|
count := len(tabsLayout.views)
|
||||||
if i >= count {
|
if index < 0 || index >= count {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
var view View
|
view := tabsLayout.views[index]
|
||||||
if count == 1 {
|
view.setParentID("")
|
||||||
view = tabsLayout.views[0]
|
|
||||||
tabsLayout.views = []View{}
|
|
||||||
for _, listener := range tabsLayout.tabListener {
|
|
||||||
listener(tabsLayout, 0, 0)
|
|
||||||
}
|
|
||||||
tabsLayout.propertyChangedEvent(Current)
|
|
||||||
|
|
||||||
} else {
|
|
||||||
current := tabsLayout.currentItem()
|
|
||||||
removeCurrent := (i == current)
|
|
||||||
if i < current || (removeCurrent && i == count-1) {
|
|
||||||
tabsLayout.properties[Current] = current - 1
|
|
||||||
for _, listener := range tabsLayout.tabListener {
|
|
||||||
listener(tabsLayout, current-1, current)
|
|
||||||
}
|
|
||||||
defer tabsLayout.propertyChangedEvent(Current)
|
|
||||||
}
|
|
||||||
view = tabsLayout.viewsContainerData.RemoveView(index)
|
|
||||||
}
|
|
||||||
|
|
||||||
view.SetChangeListener(Title, nil)
|
view.SetChangeListener(Title, nil)
|
||||||
view.SetChangeListener(Icon, nil)
|
view.SetChangeListener(Icon, nil)
|
||||||
view.SetChangeListener(TabCloseButton, nil)
|
view.SetChangeListener(TabCloseButton, nil)
|
||||||
|
|
||||||
|
current := tabsLayout.currentItem()
|
||||||
|
if index < current || (index == current && current > 0) {
|
||||||
|
current--
|
||||||
|
}
|
||||||
|
|
||||||
|
if len(tabsLayout.views) == 1 {
|
||||||
|
tabsLayout.views = []View{}
|
||||||
|
current = -1
|
||||||
|
} else if index == 0 {
|
||||||
|
tabsLayout.views = tabsLayout.views[1:]
|
||||||
|
} else if index == count-1 {
|
||||||
|
tabsLayout.views = tabsLayout.views[:index]
|
||||||
|
} else {
|
||||||
|
tabsLayout.views = append(tabsLayout.views[:index], tabsLayout.views[index+1:]...)
|
||||||
|
}
|
||||||
|
|
||||||
|
updateInnerHTML(tabsLayout.parentHTMLID(), tabsLayout.session)
|
||||||
|
tabsLayout.propertyChangedEvent(Content)
|
||||||
|
|
||||||
|
delete(tabsLayout.properties, Current)
|
||||||
|
tabsLayout.set(Current, current)
|
||||||
return view
|
return view
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tabsLayout *tabsLayoutData) currentID() string {
|
||||||
|
return fmt.Sprintf("%s-%d", tabsLayout.htmlID(), tabsLayout.currentItem())
|
||||||
|
}
|
||||||
|
|
||||||
func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Builder) {
|
func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Builder) {
|
||||||
tabsLayout.viewsContainerData.htmlProperties(self, buffer)
|
tabsLayout.viewsContainerData.htmlProperties(self, buffer)
|
||||||
buffer.WriteString(` data-inactiveTabStyle="`)
|
buffer.WriteString(` data-inactiveTabStyle="`)
|
||||||
|
@ -679,9 +689,7 @@ func (tabsLayout *tabsLayoutData) htmlProperties(self View, buffer *strings.Buil
|
||||||
buffer.WriteString(`" data-activeTabStyle="`)
|
buffer.WriteString(`" data-activeTabStyle="`)
|
||||||
buffer.WriteString(tabsLayout.activeTabStyle())
|
buffer.WriteString(tabsLayout.activeTabStyle())
|
||||||
buffer.WriteString(`" data-current="`)
|
buffer.WriteString(`" data-current="`)
|
||||||
buffer.WriteString(tabsLayout.htmlID())
|
buffer.WriteString(tabsLayout.currentID())
|
||||||
buffer.WriteRune('-')
|
|
||||||
buffer.WriteString(strconv.Itoa(tabsLayout.currentItem()))
|
|
||||||
buffer.WriteRune('"')
|
buffer.WriteRune('"')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -141,12 +141,11 @@ func textToJS(text string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
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 := textView.getRaw(Text); value != nil {
|
||||||
if !GetNotTranslate(textView, "") {
|
if text, ok := value.(string); ok {
|
||||||
value, _ = textView.session.GetString(value)
|
text, _ = textView.session.GetString(text)
|
||||||
|
buffer.WriteString(textToJS(text))
|
||||||
}
|
}
|
||||||
|
|
||||||
buffer.WriteString(textToJS(value))
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -44,7 +44,12 @@ func (container *viewsContainerData) Views() []View {
|
||||||
if container.views == nil {
|
if container.views == nil {
|
||||||
container.views = []View{}
|
container.views = []View{}
|
||||||
}
|
}
|
||||||
return container.views
|
if count := len(container.views); count > 0 {
|
||||||
|
views := make([]View, count)
|
||||||
|
copy(views, container.views)
|
||||||
|
return views
|
||||||
|
}
|
||||||
|
return []View{}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append appends a view to the end of the list of a view children
|
// Append appends a view to the end of the list of a view children
|
||||||
|
|
Loading…
Reference in New Issue