Flutter web, custom cursor (#7545)

* Flutter web, custom cursor

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* trivial changes

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* Flutter web, custom cursor, use date after 'updateGetKey()'

Signed-off-by: fufesou <shuanglongchen@yeah.net>

* trivial changes

Signed-off-by: fufesou <shuanglongchen@yeah.net>

---------

Signed-off-by: fufesou <shuanglongchen@yeah.net>
This commit is contained in:
fufesou
2024-03-29 10:52:32 +08:00
committed by GitHub
parent 4b0e88ce46
commit 3ef9824d8e
5 changed files with 192 additions and 39 deletions

View File

@@ -333,6 +333,9 @@ window.setByName = (name, value) => {
break;
case 'change_prefer_codec':
curConn.changePreferCodec(value);
case 'cursor':
setCustomCursor(value);
break;
default:
break;
}
@@ -552,6 +555,23 @@ export function getVersionNumber(v) {
}
}
// Set the cursor for the flutter-view element
function setCustomCursor(value) {
try {
const obj = JSON.parse(value);
// document querySelector or evaluate can not find the custom element
var body = document.body;
for (var i = 0; i < body.children.length; i++) {
var child = body.children[i];
if (child.tagName == 'FLUTTER-VIEW') {
child.style.cursor = `url(${obj.url}) ${obj.hotx} ${obj.hoty}, auto`;
}
}
} catch (e) {
console.error('Failed to set custom cursor: ' + e.message);
}
}
// ========================== options begin ==========================
function setUserDefaultOption(value) {
try {