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 {
|
func (button *checkboxData) setChangedListener(value any) bool {
|
||||||
if value == nil {
|
listeners, ok := valueToEventListeners[Checkbox, bool](value)
|
||||||
if len(button.checkedListeners) > 0 {
|
if !ok {
|
||||||
button.checkedListeners = []func(Checkbox, bool){}
|
return false
|
||||||
}
|
} else if listeners == nil {
|
||||||
return true
|
listeners = []func(Checkbox, bool){}
|
||||||
}
|
|
||||||
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
button.checkedListeners = listeners
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -370,7 +322,7 @@ func (button *checkboxData) htmlSubviews(self View, buffer *strings.Builder) {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (button *checkboxData) cssHorizontalAlign() string {
|
func (button *checkboxData) cssHorizontalAlign() string {
|
||||||
align := GetCheckboxHorizontalAlign(button, "")
|
align := GetHorizontalAlign(button, "")
|
||||||
values := enumProperties[CellHorizontalAlign].cssValues
|
values := enumProperties[CellHorizontalAlign].cssValues
|
||||||
if align >= 0 && align < len(values) {
|
if align >= 0 && align < len(values) {
|
||||||
return values[align]
|
return values[align]
|
||||||
|
@ -379,7 +331,7 @@ func (button *checkboxData) cssHorizontalAlign() string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (button *checkboxData) cssVerticalAlign() string {
|
func (button *checkboxData) cssVerticalAlign() string {
|
||||||
align := GetCheckboxVerticalAlign(button, "")
|
align := GetVerticalAlign(button, "")
|
||||||
values := enumProperties[CellVerticalAlign].cssValues
|
values := enumProperties[CellVerticalAlign].cssValues
|
||||||
if align >= 0 && align < len(values) {
|
if align >= 0 && align < len(values) {
|
||||||
return values[align]
|
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)
|
// GetVerticalAlign return the vertical align of a list: TopAlign (0), BottomAlign (1), CenterAlign (2), StretchAlign (3)
|
||||||
func GetVerticalAlign(view View) int {
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
if align, ok := enumProperty(view, VerticalAlign, view.Session(), TopAlign); ok {
|
func GetVerticalAlign(view View, subviewID string) int {
|
||||||
return align
|
return enumStyledProperty(view, subviewID, VerticalAlign, TopAlign, false)
|
||||||
}
|
|
||||||
return TopAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetHorizontalAlign return the vertical align of a list: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
// GetHorizontalAlign return the vertical align of a list/checkbox: LeftAlign (0), RightAlign (1), CenterAlign (2), StretchAlign (3)
|
||||||
func GetHorizontalAlign(view View) int {
|
// If the second argument (subviewID) is "" then a value from the first argument (view) is returned.
|
||||||
if align, ok := enumProperty(view, HorizontalAlign, view.Session(), LeftAlign); ok {
|
func GetHorizontalAlign(view View, subviewID string) int {
|
||||||
return align
|
return enumStyledProperty(view, subviewID, HorizontalAlign, LeftAlign, false)
|
||||||
}
|
|
||||||
return LeftAlign
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetListItemClickedListeners returns a ListItemClickedListener of the ListView.
|
// GetListItemClickedListeners returns a ListItemClickedListener of the ListView.
|
||||||
|
|
Loading…
Reference in New Issue