forked from mbk-lab/rui_orig
bug fixing
This commit is contained in:
parent
3d52de161b
commit
379d98fe4a
64
checkbox.go
64
checkbox.go
|
@ -206,61 +206,13 @@ func checkboxKeyListener(view View, event KeyEvent) {
|
|||
}
|
||||
|
||||
func (button *checkboxData) setChangedListener(value any) bool {
|
||||
if value == nil {
|
||||
if len(button.checkedListeners) > 0 {
|
||||
button.checkedListeners = []func(Checkbox, bool){}
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
switch value := value.(type) {
|
||||
case func(Checkbox, bool):
|
||||
button.checkedListeners = []func(Checkbox, bool){value}
|
||||
|
||||
case func(bool):
|
||||
fn := func(_ Checkbox, checked bool) {
|
||||
value(checked)
|
||||
}
|
||||
button.checkedListeners = []func(Checkbox, bool){fn}
|
||||
|
||||
case []func(Checkbox, bool):
|
||||
button.checkedListeners = value
|
||||
|
||||
case []func(bool):
|
||||
listeners := make([]func(Checkbox, bool), len(value))
|
||||
for i, val := range value {
|
||||
if val == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
listeners[i] = func(_ Checkbox, checked bool) {
|
||||
val(checked)
|
||||
}
|
||||
}
|
||||
button.checkedListeners = listeners
|
||||
|
||||
case []any:
|
||||
listeners := make([]func(Checkbox, bool), len(value))
|
||||
for i, val := range value {
|
||||
if val == nil {
|
||||
return false
|
||||
}
|
||||
|
||||
switch val := val.(type) {
|
||||
case func(Checkbox, bool):
|
||||
listeners[i] = val
|
||||
|
||||
case func(bool):
|
||||
listeners[i] = func(_ Checkbox, date bool) {
|
||||
val(date)
|
||||
}
|
||||
|
||||
default:
|
||||
return false
|
||||
}
|
||||
}
|
||||
button.checkedListeners = listeners
|
||||
listeners, ok := valueToEventListeners[Checkbox, bool](value)
|
||||
if !ok {
|
||||
return false
|
||||
} else if listeners == nil {
|
||||
listeners = []func(Checkbox, bool){}
|
||||
}
|
||||
button.checkedListeners = listeners
|
||||
return true
|
||||
}
|
||||
|
||||
|
@ -370,7 +322,7 @@ func (button *checkboxData) htmlSubviews(self View, buffer *strings.Builder) {
|
|||
}
|
||||
|
||||
func (button *checkboxData) cssHorizontalAlign() string {
|
||||
align := GetCheckboxHorizontalAlign(button, "")
|
||||
align := GetHorizontalAlign(button, "")
|
||||
values := enumProperties[CellHorizontalAlign].cssValues
|
||||
if align >= 0 && align < len(values) {
|
||||
return values[align]
|
||||
|
@ -379,7 +331,7 @@ func (button *checkboxData) cssHorizontalAlign() string {
|
|||
}
|
||||
|
||||
func (button *checkboxData) cssVerticalAlign() string {
|
||||
align := GetCheckboxVerticalAlign(button, "")
|
||||
align := GetVerticalAlign(button, "")
|
||||
values := enumProperties[CellVerticalAlign].cssValues
|
||||
if align >= 0 && align < len(values) {
|
||||
return values[align]
|
||||
|
|
18
listView.go
18
listView.go
|
@ -1086,19 +1086,15 @@ func (listView *listViewData) onItemResize(self View, index string, x, y, width,
|
|||
}
|
||||
|
||||
// GetVerticalAlign return the vertical align of a list: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3)
|
||||
func GetVerticalAlign(view View) int {
|
||||
if align, ok := enumProperty(view, VerticalAlign, view.Session(), TopAlign); ok {
|
||||
return align
|
||||
}
|
||||
return TopAlign
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetVerticalAlign(view View, subviewID string) int {
|
||||
return enumStyledProperty(view, subviewID, VerticalAlign, TopAlign, false)
|
||||
}
|
||||
|
||||
// GetHorizontalAlign return the vertical align of a list: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
||||
func GetHorizontalAlign(view View) int {
|
||||
if align, ok := enumProperty(view, HorizontalAlign, view.Session(), LeftAlign); ok {
|
||||
return align
|
||||
}
|
||||
return LeftAlign
|
||||
// GetHorizontalAlign return the vertical align of a list/checkbox: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
||||
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||
func GetHorizontalAlign(view View, subviewID string) int {
|
||||
return enumStyledProperty(view, subviewID, HorizontalAlign, LeftAlign, false)
|
||||
}
|
||||
|
||||
// GetListItemClickedListeners returns a ListItemClickedListener of the ListView.
|
||||
|
|
Loading…
Reference in New Issue