focus event
This commit is contained in:
parent
917e638538
commit
780189a1a6
4 changed files with 37 additions and 11 deletions
|
|
@ -21,7 +21,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|||
const decoder = new TextDecoder();
|
||||
const encoder = new TextEncoder();
|
||||
|
||||
let memorycounter = -1;
|
||||
let memorycounter = 0;
|
||||
const jsmemory = new Map();
|
||||
const eventHandlers = new Map();
|
||||
|
||||
|
|
@ -188,7 +188,17 @@ function addFocusListener(ptr, handlerID) {
|
|||
|
||||
const handler = function (event) {
|
||||
const { ExecuteFocusHandler } = window.crafter_webbuild_wasi.instance.exports;
|
||||
ExecuteFocusHandler(handlerID);
|
||||
if(event.relatedTarget) {
|
||||
const targetKey = ++memorycounter;
|
||||
const relatedTargetKey = ++memorycounter;
|
||||
jsmemory.set(targetKey, event.target);
|
||||
jsmemory.set(relatedTargetKey, event.relatedTarget);
|
||||
ExecuteFocusHandler(handlerID, targetKey, relatedTargetKey);
|
||||
} else {
|
||||
const targetKey = ++memorycounter;
|
||||
jsmemory.set(targetKey, event.target);
|
||||
ExecuteFocusHandler(handlerID, targetKey, 0);
|
||||
}
|
||||
};
|
||||
|
||||
eventHandlers.set(`${ptr}-${handlerID}-focus`, handler);
|
||||
|
|
@ -209,7 +219,17 @@ function addBlurListener(ptr, handlerID) {
|
|||
|
||||
const handler = function (event) {
|
||||
const { ExecuteBlurHandler } = window.crafter_webbuild_wasi.instance.exports;
|
||||
ExecuteBlurHandler(handlerID);
|
||||
if(event.relatedTarget) {
|
||||
const targetKey = ++memorycounter;
|
||||
const relatedTargetKey = ++memorycounter;
|
||||
jsmemory.set(targetKey, event.target);
|
||||
jsmemory.set(relatedTargetKey, event.relatedTarget);
|
||||
ExecuteBlurHandler(handlerID, targetKey, relatedTargetKey);
|
||||
} else {
|
||||
const targetKey = ++memorycounter;
|
||||
jsmemory.set(targetKey, event.target);
|
||||
ExecuteBlurHandler(handlerID, targetKey, 0);
|
||||
}
|
||||
};
|
||||
|
||||
eventHandlers.set(`${ptr}-${handlerID}-blur`, handler);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue