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) {
event.stopPropagation();
if(element.getAttribute("data-disabled") == "1") {
return
}
var selected = false;
if (element.classList) {
const focusStyle = getListFocusedItemStyle(element);
@ -707,6 +711,9 @@ function findRightListItem(list, x, y) {
var count = list.childNodes.length;
for (var i = 0; i < count; i++) {
var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetLeft >= x) {
if (result) {
var result_dy = Math.abs(result.offsetTop - y);
@ -728,6 +735,9 @@ function findLeftListItem(list, x, y) {
var count = list.childNodes.length;
for (var i = 0; i < count; i++) {
var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetLeft < x) {
if (result) {
var result_dy = Math.abs(result.offsetTop - y);
@ -749,6 +759,9 @@ function findTopListItem(list, x, y) {
var count = list.childNodes.length;
for (var i = 0; i < count; i++) {
var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetTop < y) {
if (result) {
var result_dx = Math.abs(result.offsetLeft - x);
@ -770,6 +783,9 @@ function findBottomListItem(list, x, y) {
var count = list.childNodes.length;
for (var i = 0; i < count; i++) {
var item = list.childNodes[i];
if (item.getAttribute("data-disabled") == "1") {
continue;
}
if (item.offsetTop >= y) {
if (result) {
var result_dx = Math.abs(result.offsetLeft - x);
@ -818,50 +834,77 @@ function listViewKeyDownEvent(element, event) {
if (current) {
var item
switch (key) {
case " ":
case "Enter":
var message = "itemClick{session=" + sessionID + ",id=" + element.id + "}";
sendMessage(message);
break;
case " ":
case "Enter":
var message = "itemClick{session=" + sessionID + ",id=" + element.id + "}";
sendMessage(message);
break;
case "ArrowLeft":
item = findLeftListItem(element, current.offsetLeft, current.offsetTop);
break;
case "ArrowRight":
item = findRightListItem(element, current.offsetLeft + current.offsetWidth, current.offsetTop);
break;
case "ArrowDown":
item = findBottomListItem(element, current.offsetLeft, current.offsetTop + current.offsetHeight);
break;
case "ArrowLeft":
item = findLeftListItem(element, current.offsetLeft, current.offsetTop);
break;
case "ArrowRight":
item = findRightListItem(element, current.offsetLeft + current.offsetWidth, current.offsetTop);
break;
case "ArrowDown":
item = findBottomListItem(element, current.offsetLeft, current.offsetTop + current.offsetHeight);
break;
case "ArrowUp":
item = findTopListItem(element, current.offsetLeft, current.offsetTop);
break;
case "ArrowUp":
item = findTopListItem(element, current.offsetLeft, current.offsetTop);
break;
case "Home":
item = element.childNodes[0];
break;
case "Home":
item = element.childNodes[0];
break;
case "End":
item = element.childNodes[element.childNodes.length - 1];
break;
case "End":
item = element.childNodes[element.childNodes.length - 1];
break;
case "PageUp":
// TODO
break;
case "PageUp":
// TODO
break;
case "PageDown":
// TODO
break;
case "PageDown":
// TODO
break;
default:
return;
default:
return;
}
if (item && item !== current) {
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;`)
listView.itemSize(self, buffer)
if !listView.adapter.IsListItemEnabled(i) {
buffer.WriteString(`" data-disabled="1`)
}
buffer.WriteString(`">`)
buffer.WriteString(itemDiv)
@ -796,6 +799,9 @@ func (listView *listViewData) noneCheckboxSubviews(self View, buffer *strings.Bu
}
buffer.WriteString(`" `)
buffer.WriteString(itemStyle)
if !listView.adapter.IsListItemEnabled(i) {
buffer.WriteString(` data-disabled="1"`)
}
buffer.WriteString(`>`)
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 {
return NewTextView(popup.session, Params{
view := NewTextView(popup.session, Params{
Text: popup.items[index],
Style: "ruiPopupMenuItem",
})
if !popup.IsListItemEnabled(index) {
view.Set(TextColor, "@ruiDisabledTextColor")
}
return view
}
func (popup *popupMenuData) IsListItemEnabled(index int) bool {