forked from mbk-lab/rui_orig
2
0
Fork 0

Bug fixing

This commit is contained in:
anoshenko 2023-05-03 15:16:03 +03:00
parent b7a0aa9a6d
commit f75435eb6c
3 changed files with 87 additions and 34 deletions

View File

@ -590,6 +590,10 @@ function selectDropDownListItem(elementId, number) {
function listItemClickEvent(element, event) { function listItemClickEvent(element, event) {
event.stopPropagation(); event.stopPropagation();
if(element.getAttribute("data-disabled") == "1") {
return
}
var selected = false; var selected = false;
if (element.classList) { if (element.classList) {
const focusStyle = getListFocusedItemStyle(element); const focusStyle = getListFocusedItemStyle(element);
@ -707,6 +711,9 @@ function findRightListItem(list, x, y) {
var count = list.childNodes.length; var count = list.childNodes.length;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var item = list.childNodes[i]; var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetLeft >= x) { if (item.offsetLeft >= x) {
if (result) { if (result) {
var result_dy = Math.abs(result.offsetTop - y); var result_dy = Math.abs(result.offsetTop - y);
@ -728,6 +735,9 @@ function findLeftListItem(list, x, y) {
var count = list.childNodes.length; var count = list.childNodes.length;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var item = list.childNodes[i]; var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetLeft < x) { if (item.offsetLeft < x) {
if (result) { if (result) {
var result_dy = Math.abs(result.offsetTop - y); var result_dy = Math.abs(result.offsetTop - y);
@ -749,6 +759,9 @@ function findTopListItem(list, x, y) {
var count = list.childNodes.length; var count = list.childNodes.length;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var item = list.childNodes[i]; var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetTop < y) { if (item.offsetTop < y) {
if (result) { if (result) {
var result_dx = Math.abs(result.offsetLeft - x); var result_dx = Math.abs(result.offsetLeft - x);
@ -770,6 +783,9 @@ function findBottomListItem(list, x, y) {
var count = list.childNodes.length; var count = list.childNodes.length;
for (var i = 0; i < count; i++) { for (var i = 0; i < count; i++) {
var item = list.childNodes[i]; var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetTop >= y) { if (item.offsetTop >= y) {
if (result) { if (result) {
var result_dx = Math.abs(result.offsetLeft - x); var result_dx = Math.abs(result.offsetLeft - x);
@ -862,6 +878,33 @@ function listViewKeyDownEvent(element, event) {
if (item && item !== current) { if (item && item !== current) {
selectListItem(element, item, true); selectListItem(element, item, true);
} }
} else {
switch (key) {
case " ":
case "Enter":
case "ArrowLeft":
case "ArrowUp":
case "ArrowRight":
case "ArrowDown":
case "Home":
case "End":
case "PageUp":
case "PageDown":
var list = element.childNodes[0];
var count = list.childNodes.length;
for (var i = 0; i < count; i++) {
var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
selectListItem(element, item, true);
return;
}
break;
default:
return;
}
} }
} }

View File

@ -740,6 +740,9 @@ func (listView *listViewData) checkboxSubviews(self View, buffer *strings.Builde
} }
buffer.WriteString(`" onclick="listItemClickEvent(this, event)" data-left="0" data-top="0" data-width="0" data-height="0" style="display: grid; justify-items: stretch; align-items: stretch;`) buffer.WriteString(`" onclick="listItemClickEvent(this, event)" data-left="0" data-top="0" data-width="0" data-height="0" style="display: grid; justify-items: stretch; align-items: stretch;`)
listView.itemSize(self, buffer) listView.itemSize(self, buffer)
if !listView.adapter.IsListItemEnabled(i) {
buffer.WriteString(`" data-disabled="1`)
}
buffer.WriteString(`">`) buffer.WriteString(`">`)
buffer.WriteString(itemDiv) buffer.WriteString(itemDiv)
@ -796,6 +799,9 @@ func (listView *listViewData) noneCheckboxSubviews(self View, buffer *strings.Bu
} }
buffer.WriteString(`" `) buffer.WriteString(`" `)
buffer.WriteString(itemStyle) buffer.WriteString(itemStyle)
if !listView.adapter.IsListItemEnabled(i) {
buffer.WriteString(` data-disabled="1"`)
}
buffer.WriteString(`>`) buffer.WriteString(`>`)
if view := listView.getItemView(i); view != nil { if view := listView.getItemView(i); view != nil {

View File

@ -127,10 +127,14 @@ func (popup *popupMenuData) ListSize() int {
} }
func (popup *popupMenuData) ListItem(index int, session Session) View { func (popup *popupMenuData) ListItem(index int, session Session) View {
return NewTextView(popup.session, Params{ view := NewTextView(popup.session, Params{
Text: popup.items[index], Text: popup.items[index],
Style: "ruiPopupMenuItem", Style: "ruiPopupMenuItem",
}) })
if !popup.IsListItemEnabled(index) {
view.Set(TextColor, "@ruiDisabledTextColor")
}
return view
} }
func (popup *popupMenuData) IsListItemEnabled(index int) bool { func (popup *popupMenuData) IsListItemEnabled(index int) bool {