diff --git a/app_scripts.js b/app_scripts.js index 40c41fd..73c6df8 100644 --- a/app_scripts.js +++ b/app_scripts.js @@ -609,7 +609,7 @@ function listItemClickEvent(element, event) { selected = element.className.indexOf("ruiListItemFocused") >= 0 || element.className.indexOf("ruiListItemSelected") >= 0; } - var list = element.parentNode + var list = element.parentNode.parentNode if (list) { if (!selected) { selectListItem(list, element, true) @@ -705,6 +705,7 @@ function selectListItem(element, item, needSendMessage) { } function findRightListItem(list, x, y) { + list = list.childNodes[0]; var result; var count = list.childNodes.length; for (var i = 0; i < count; i++) { @@ -725,6 +726,7 @@ function findRightListItem(list, x, y) { } function findLeftListItem(list, x, y) { + list = list.childNodes[0]; var result; var count = list.childNodes.length; for (var i = 0; i < count; i++) { @@ -745,6 +747,7 @@ function findLeftListItem(list, x, y) { } function findTopListItem(list, x, y) { + list = list.childNodes[0]; var result; var count = list.childNodes.length; for (var i = 0; i < count; i++) { @@ -765,6 +768,7 @@ function findTopListItem(list, x, y) { } function findBottomListItem(list, x, y) { + list = list.childNodes[0]; var result; var count = list.childNodes.length; for (var i = 0; i < count; i++) { diff --git a/app_styles.css b/app_styles.css index 8c327a9..dc9dfa3 100644 --- a/app_styles.css +++ b/app_styles.css @@ -98,8 +98,10 @@ body { .ruiListView { overflow: auto; + /* display: flex; align-content: stretch; + */ } /* @media (prefers-color-scheme: light) { diff --git a/listLayout.go b/listLayout.go index dabc6eb..442efec 100644 --- a/listLayout.go +++ b/listLayout.go @@ -125,11 +125,20 @@ func GetListOrientation(view View, subviewID string) int { if subviewID != "" { view = ViewByID(view, subviewID) } - if view == nil { - return 0 + + if view != nil { + if orientation, ok := valueToOrientation(view.Get(Orientation), view.Session()); ok { + return orientation + } + + if value, ok := valueFromStyle(view, Orientation); ok { + if orientation, ok := valueToOrientation(value, view.Session()); ok { + return orientation + } + } } - orientation, _ := getOrientation(view, view.Session()) - return orientation + + return 0 } // GetListWrap returns the wrap type of a ListLayout or ListView subview: @@ -140,7 +149,7 @@ func GetListWrap(view View, subviewID string) int { view = ViewByID(view, subviewID) } if view != nil { - if result, ok := enumProperty(view, Wrap, view.Session(), 0); ok { + if result, ok := enumStyledProperty(view, Wrap, 0); ok { return result } } diff --git a/listView.go b/listView.go index b31a714..0f4f0f3 100644 --- a/listView.go +++ b/listView.go @@ -215,11 +215,8 @@ func (listView *listViewData) set(tag string, value interface{}) bool { return true } - case Orientation, Wrap: - if listView.viewData.set(tag, value) { - updateCSSStyle(listView.htmlID(), listView.session) - return true - } + case Orientation, Wrap, VerticalAlign, HorizontalAlign, Style, StyleDisabled: + result = listView.viewData.set(tag, value) case ItemWidth, ItemHeight: result = listView.setSizeProperty(tag, value) @@ -575,36 +572,6 @@ func (listView *listViewData) getItemFrames() []Frame { return listView.itemFrame } -func (listView *listViewData) htmlProperties(self View, buffer *strings.Builder) { - buffer.WriteString(`onfocus="listViewFocusEvent(this, event)" onblur="listViewBlurEvent(this, event)"`) - buffer.WriteString(` onkeydown="listViewKeyDownEvent(this, event)" data-focusitemstyle="`) - buffer.WriteString(listView.currentStyle()) - buffer.WriteString(`" data-bluritemstyle="`) - buffer.WriteString(listView.currentInactiveStyle()) - buffer.WriteString(`"`) - current := GetListViewCurrent(listView, "") - if listView.adapter != nil && current >= 0 && current < listView.adapter.ListSize() { - buffer.WriteString(` data-current="`) - buffer.WriteString(listView.htmlID()) - buffer.WriteRune('-') - buffer.WriteString(strconv.Itoa(current)) - buffer.WriteRune('"') - } -} - -func (listView *listViewData) cssStyle(self View, builder cssBuilder) { - listView.viewData.cssStyle(self, builder) - - if GetListWrap(listView, "") != WrapOff { - switch GetListOrientation(listView, "") { - case TopDownOrientation, BottomUpOrientation: - builder.add(`max-height`, `100%`) - default: - builder.add(`max-width`, `100%`) - } - } -} - func (listView *listViewData) itemAlign(self View, buffer *strings.Builder) { values := enumProperties[ItemHorizontalAlign].cssValues if hAlign := GetListItemHorizontalAlign(listView, ""); hAlign >= 0 && hAlign < len(values) { @@ -911,11 +878,40 @@ func (listView *listViewData) updateCheckboxItem(index int, checked bool) { session.runScript(buffer.String()) } -func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) { - if listView.adapter == nil { - return +func (listView *listViewData) htmlProperties(self View, buffer *strings.Builder) { + buffer.WriteString(`onfocus="listViewFocusEvent(this, event)" onblur="listViewBlurEvent(this, event)"`) + buffer.WriteString(` onkeydown="listViewKeyDownEvent(this, event)" data-focusitemstyle="`) + buffer.WriteString(listView.currentStyle()) + buffer.WriteString(`" data-bluritemstyle="`) + buffer.WriteString(listView.currentInactiveStyle()) + buffer.WriteString(`"`) + current := GetListViewCurrent(listView, "") + if listView.adapter != nil && current >= 0 && current < listView.adapter.ListSize() { + buffer.WriteString(` data-current="`) + buffer.WriteString(listView.htmlID()) + buffer.WriteRune('-') + buffer.WriteString(strconv.Itoa(current)) + buffer.WriteRune('"') } - if listView.adapter.ListSize() == 0 { +} + +/* +func (listView *listViewData) cssStyle(self View, builder cssBuilder) { + listView.viewData.cssStyle(self, builder) + + if GetListWrap(listView, "") != WrapOff { + switch GetListOrientation(listView, "") { + case TopDownOrientation, BottomUpOrientation: + builder.add(`max-height`, `100%`) + default: + builder.add(`max-width`, `100%`) + } + } +} +*/ + +func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) { + if listView.adapter == nil || listView.adapter.ListSize() == 0 { return } @@ -924,12 +920,129 @@ func (listView *listViewData) htmlSubviews(self View, buffer *strings.Builder) { defer listView.session.setIgnoreViewUpdates(false) } + buffer.WriteString(`
`) + checkbox := GetListViewCheckbox(listView, "") if checkbox == NoneCheckbox { listView.noneCheckboxSubviews(self, buffer) } else { listView.checkboxSubviews(self, buffer, checkbox) } + + buffer.WriteString(`
`) } func (listView *listViewData) handleCommand(self View, command string, data DataObject) bool { diff --git a/viewStyle.go b/viewStyle.go index 98ce8f1..46c7e55 100644 --- a/viewStyle.go +++ b/viewStyle.go @@ -291,7 +291,7 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { } wrap, _ := enumProperty(style, Wrap, session, 0) - orientation, ok := getOrientation(style, session) + orientation, ok := valueToOrientation(style.Get(Orientation), session) if ok || wrap > 0 { cssText := enumProperties[Orientation].cssValues[orientation] switch wrap { @@ -360,9 +360,9 @@ func (style *viewStyle) cssViewStyle(builder cssBuilder, session Session) { case StretchAlign: if rows { - builder.add(hAlignTag, `stretch`) + builder.add(vAlignTag, `stretch`) } else { - builder.add(hAlignTag, `space-between`) + builder.add(vAlignTag, `space-between`) } } } diff --git a/viewStyleGet.go b/viewStyleGet.go index 1dbaa51..738257e 100644 --- a/viewStyleGet.go +++ b/viewStyleGet.go @@ -4,8 +4,8 @@ import ( "strings" ) -func getOrientation(style Properties, session Session) (int, bool) { - if value := style.Get(Orientation); value != nil { +func valueToOrientation(value interface{}, session Session) (int, bool) { + if value != nil { switch value := value.(type) { case int: return value, true @@ -30,10 +30,14 @@ func getOrientation(style Properties, session Session) (int, bool) { } } } - return 0, false } +/* +func getOrientation(style Properties, session Session) (int, bool) { + return valueToOrientation(style.Get(Orientation), session) +} +*/ func (style *viewStyle) Get(tag string) interface{} { return style.get(strings.ToLower(tag)) }