Generalize Query system for use in use_eval and node querys

This commit is contained in:
Evan Almloff committed 2023-03-23 15:19:00 -05:00
1 parent 7636c046fa
commit fa9f0d0f6c
8 files changed
+186 -282

No files matched your search

+4 -29
View File
@@ -227,51 +227,26 @@ class Interpreter {
ScrollTo(id, behavior) {
const node = this.nodes[id];
if (!node) {
return;
return false;
}
node.scrollIntoView({
behavior: behavior
});
return {
type: "ScrollTo",
};
return true;
}
/// Set the focus on the element
SetFocus(id, focus) {
const node = this.nodes[id];
if (!node) {
return;
return false;
}
if (focus) {
node.focus();
} else {
node.blur();
}
return {
type: "SetFocus",
};
}
handleNodeUpdate(edit) {
let data;
switch (edit.data.type) {
case "SetFocus":
data = this.SetFocus(edit.id, edit.data.focus);
break;
case "ScrollTo":
data = this.ScrollTo(edit.id, edit.data.behavior);
break;
case "GetClientRect":
data = this.GetClientRect(edit.id);
break;
}
window.ipc.postMessage(
serializeIpcMessage("node_update", {
id: edit.request_id,
data: data
})
);
return true;
}
handleEdits(edits) {