mirror of https://github.com/anoshenko/rui.git
Bug fixing
This commit is contained in:
parent
9e4fdccd79
commit
b1f085b891
|
@ -34,6 +34,7 @@ func newColorPicker(session Session) View {
|
|||
func (picker *colorPickerData) init(session Session) {
|
||||
picker.viewData.init(session)
|
||||
picker.tag = "ColorPicker"
|
||||
picker.hasHtmlDisabled = true
|
||||
picker.colorChangedListeners = []func(ColorPicker, Color, Color){}
|
||||
picker.properties[Padding] = Px(0)
|
||||
}
|
||||
|
@ -153,13 +154,6 @@ func (picker *colorPickerData) htmlProperties(self View, buffer *strings.Builder
|
|||
}
|
||||
}
|
||||
|
||||
func (picker *colorPickerData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
picker.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (picker *colorPickerData) handleCommand(self View, command string, data DataObject) bool {
|
||||
switch command {
|
||||
case "textChanged":
|
||||
|
|
|
@ -188,10 +188,6 @@ func (customView *CustomViewData) htmlProperties(self View, buffer *strings.Buil
|
|||
customView.superView.htmlProperties(customView.superView, buffer)
|
||||
}
|
||||
|
||||
func (customView *CustomViewData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
customView.superView.htmlDisabledProperties(customView.superView, buffer)
|
||||
}
|
||||
|
||||
func (customView *CustomViewData) cssStyle(self View, builder cssBuilder) {
|
||||
customView.superView.cssStyle(customView.superView, builder)
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ func newDatePicker(session Session) View {
|
|||
func (picker *datePickerData) init(session Session) {
|
||||
picker.viewData.init(session)
|
||||
picker.tag = "DatePicker"
|
||||
picker.hasHtmlDisabled = true
|
||||
picker.dateChangedListeners = []func(DatePicker, time.Time, time.Time){}
|
||||
}
|
||||
|
||||
|
@ -303,13 +304,6 @@ func (picker *datePickerData) htmlProperties(self View, buffer *strings.Builder)
|
|||
}
|
||||
}
|
||||
|
||||
func (picker *datePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
picker.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (picker *datePickerData) handleCommand(self View, command string, data DataObject) bool {
|
||||
switch command {
|
||||
case "textChanged":
|
||||
|
|
|
@ -39,6 +39,7 @@ func newDropDownList(session Session) View {
|
|||
func (list *dropDownListData) init(session Session) {
|
||||
list.viewData.init(session)
|
||||
list.tag = "DropDownList"
|
||||
list.hasHtmlDisabled = true
|
||||
list.items = []string{}
|
||||
list.disabledItems = []any{}
|
||||
list.dropDownListener = []func(DropDownList, int, int){}
|
||||
|
@ -370,13 +371,6 @@ func (list *dropDownListData) htmlProperties(self View, buffer *strings.Builder)
|
|||
buffer.WriteString(` size="1" onchange="dropDownListEvent(this, event)"`)
|
||||
}
|
||||
|
||||
func (list *dropDownListData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
list.viewData.htmlDisabledProperties(self, buffer)
|
||||
if IsDisabled(list) {
|
||||
buffer.WriteString(`disabled`)
|
||||
}
|
||||
}
|
||||
|
||||
func (list *dropDownListData) onSelectedItemChanged(number, old int) {
|
||||
for _, listener := range list.dropDownListener {
|
||||
listener(list, number, old)
|
||||
|
|
|
@ -58,6 +58,7 @@ func newEditView(session Session) View {
|
|||
|
||||
func (edit *editViewData) init(session Session) {
|
||||
edit.viewData.init(session)
|
||||
edit.hasHtmlDisabled = true
|
||||
edit.textChangeListeners = []func(EditView, string, string){}
|
||||
edit.tag = "EditView"
|
||||
}
|
||||
|
@ -466,13 +467,6 @@ func (edit *editViewData) htmlProperties(self View, buffer *strings.Builder) {
|
|||
}
|
||||
}
|
||||
|
||||
func (edit *editViewData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
edit.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (edit *editViewData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||
if GetEditViewType(edit) == MultiLineText {
|
||||
buffer.WriteString(GetText(edit))
|
||||
|
|
|
@ -83,6 +83,7 @@ func newFilePicker(session Session) View {
|
|||
func (picker *filePickerData) init(session Session) {
|
||||
picker.viewData.init(session)
|
||||
picker.tag = "FilePicker"
|
||||
picker.hasHtmlDisabled = true
|
||||
picker.files = []FileInfo{}
|
||||
picker.loader = map[int]func(FileInfo, []byte){}
|
||||
picker.fileSelectedListeners = []func(FilePicker, []FileInfo){}
|
||||
|
@ -260,13 +261,6 @@ func (picker *filePickerData) htmlProperties(self View, buffer *strings.Builder)
|
|||
}
|
||||
}
|
||||
|
||||
func (picker *filePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
picker.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (picker *filePickerData) handleCommand(self View, command string, data DataObject) bool {
|
||||
switch command {
|
||||
case "fileSelected":
|
||||
|
|
|
@ -47,6 +47,7 @@ func newNumberPicker(session Session) View {
|
|||
func (picker *numberPickerData) init(session Session) {
|
||||
picker.viewData.init(session)
|
||||
picker.tag = "NumberPicker"
|
||||
picker.hasHtmlDisabled = true
|
||||
picker.numberChangedListeners = []func(NumberPicker, float64, float64){}
|
||||
}
|
||||
|
||||
|
@ -232,13 +233,6 @@ func (picker *numberPickerData) htmlProperties(self View, buffer *strings.Builde
|
|||
buffer.WriteString(` oninput="editViewInputEvent(this)"`)
|
||||
}
|
||||
|
||||
func (picker *numberPickerData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
picker.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (picker *numberPickerData) handleCommand(self View, command string, data DataObject) bool {
|
||||
switch command {
|
||||
case "textChanged":
|
||||
|
|
|
@ -40,6 +40,7 @@ func newTimePicker(session Session) View {
|
|||
func (picker *timePickerData) init(session Session) {
|
||||
picker.viewData.init(session)
|
||||
picker.tag = "TimePicker"
|
||||
picker.hasHtmlDisabled = true
|
||||
picker.timeChangedListeners = []func(TimePicker, time.Time, time.Time){}
|
||||
}
|
||||
|
||||
|
@ -291,13 +292,6 @@ func (picker *timePickerData) htmlProperties(self View, buffer *strings.Builder)
|
|||
}
|
||||
}
|
||||
|
||||
func (picker *timePickerData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
picker.viewData.htmlDisabledProperties(self, buffer)
|
||||
}
|
||||
|
||||
func (picker *timePickerData) handleCommand(self View, command string, data DataObject) bool {
|
||||
switch command {
|
||||
case "textChanged":
|
||||
|
|
60
view.go
60
view.go
|
@ -65,7 +65,6 @@ type View interface {
|
|||
setParentID(parentID string)
|
||||
htmlSubviews(self View, buffer *strings.Builder)
|
||||
htmlProperties(self View, buffer *strings.Builder)
|
||||
htmlDisabledProperties(self View, buffer *strings.Builder)
|
||||
cssStyle(self View, builder cssBuilder)
|
||||
addToCSSStyle(addCSS map[string]string)
|
||||
|
||||
|
@ -93,6 +92,7 @@ type viewData struct {
|
|||
noResizeEvent bool
|
||||
created bool
|
||||
hasFocus bool
|
||||
hasHtmlDisabled bool
|
||||
//animation map[string]AnimationEndListener
|
||||
}
|
||||
|
||||
|
@ -135,6 +135,7 @@ func (view *viewData) init(session Session) {
|
|||
view.singleTransition = map[string]Animation{}
|
||||
view.noResizeEvent = false
|
||||
view.created = false
|
||||
view.hasHtmlDisabled = false
|
||||
}
|
||||
|
||||
func (view *viewData) Session() Session {
|
||||
|
@ -302,7 +303,6 @@ func (view *viewData) propertyChangedEvent(tag string) {
|
|||
if listener, ok := view.changeListener[tag]; ok {
|
||||
listener(view, tag)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (view *viewData) Set(tag string, value any) bool {
|
||||
|
@ -404,7 +404,35 @@ func viewPropertyChanged(view *viewData, tag string) {
|
|||
|
||||
switch tag {
|
||||
case Disabled:
|
||||
updateInnerHTML(view.parentHTMLID(), session)
|
||||
tabIndex := GetTabIndex(view, htmlID)
|
||||
enabledClass := view.htmlClass(false)
|
||||
disabledClass := view.htmlClass(true)
|
||||
session.startUpdateScript(htmlID)
|
||||
if IsDisabled(view) {
|
||||
session.updateProperty(htmlID, "data-disabled", "1")
|
||||
if view.hasHtmlDisabled {
|
||||
session.updateProperty(htmlID, "disabled", true)
|
||||
}
|
||||
if tabIndex >= 0 {
|
||||
session.updateProperty(htmlID, "tabindex", -1)
|
||||
}
|
||||
if enabledClass != disabledClass {
|
||||
session.updateProperty(htmlID, "class", disabledClass)
|
||||
}
|
||||
} else {
|
||||
session.updateProperty(htmlID, "data-disabled", "0")
|
||||
if view.hasHtmlDisabled {
|
||||
session.removeProperty(htmlID, "disabled")
|
||||
}
|
||||
if tabIndex >= 0 {
|
||||
session.updateProperty(htmlID, "tabindex", tabIndex)
|
||||
}
|
||||
if enabledClass != disabledClass {
|
||||
session.updateProperty(htmlID, "class", enabledClass)
|
||||
}
|
||||
}
|
||||
session.finishUpdateScript(htmlID)
|
||||
updateInnerHTML(htmlID, session)
|
||||
return
|
||||
|
||||
case Visibility:
|
||||
|
@ -759,20 +787,22 @@ func (view *viewData) cssStyle(self View, builder cssBuilder) {
|
|||
|
||||
func (view *viewData) htmlProperties(self View, buffer *strings.Builder) {
|
||||
view.created = true
|
||||
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` data-disabled="1"`)
|
||||
if view.hasHtmlDisabled {
|
||||
buffer.WriteString(` disabled`)
|
||||
}
|
||||
} else {
|
||||
buffer.WriteString(` data-disabled="0"`)
|
||||
}
|
||||
|
||||
if view.frame.Left != 0 || view.frame.Top != 0 || view.frame.Width != 0 || view.frame.Height != 0 {
|
||||
buffer.WriteString(fmt.Sprintf(` data-left="%g" data-top="%g" data-width="%g" data-height="%g"`,
|
||||
view.frame.Left, view.frame.Top, view.frame.Width, view.frame.Height))
|
||||
}
|
||||
}
|
||||
|
||||
func (view *viewData) htmlDisabledProperties(self View, buffer *strings.Builder) {
|
||||
if IsDisabled(self) {
|
||||
buffer.WriteString(` data-disabled="1"`)
|
||||
} else {
|
||||
buffer.WriteString(` data-disabled="0"`)
|
||||
}
|
||||
}
|
||||
|
||||
func viewHTML(view View, buffer *strings.Builder) {
|
||||
viewHTMLTag := view.htmlTag()
|
||||
buffer.WriteRune('<')
|
||||
|
@ -800,8 +830,6 @@ func viewHTML(view View, buffer *strings.Builder) {
|
|||
|
||||
buffer.WriteRune(' ')
|
||||
view.htmlProperties(view, buffer)
|
||||
buffer.WriteRune(' ')
|
||||
view.htmlDisabledProperties(view, buffer)
|
||||
|
||||
if view.isNoResizeEvent() {
|
||||
buffer.WriteString(` data-noresize="1" `)
|
||||
|
@ -810,12 +838,10 @@ func viewHTML(view View, buffer *strings.Builder) {
|
|||
}
|
||||
|
||||
if !disabled {
|
||||
if value, ok := intProperty(view, TabIndex, view.Session(), -1); ok {
|
||||
if tabIndex := GetTabIndex(view); tabIndex >= 0 {
|
||||
buffer.WriteString(`tabindex="`)
|
||||
buffer.WriteString(strconv.Itoa(value))
|
||||
buffer.WriteString(strconv.Itoa(tabIndex))
|
||||
buffer.WriteString(`" `)
|
||||
} else if view.Focusable() {
|
||||
buffer.WriteString(`tabindex="0" `)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue