fix: added EventsOffAll to windows.runtime and updated the frontend runtime wrapper (#4254)

* fix: added EventsOffAll to windows.runtime and updated the frontend runtime wrapper

---------

Co-authored-by: Lea Anthony <lea.anthony@gmail.com>
This commit is contained in:
Francesco Luzzi 2025-08-02 09:15:47 +02:00 committed by GitHub
commit ebe377f375
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 41 additions and 19 deletions

View file

@ -190,9 +190,9 @@ export function EventsOff(eventName, ...additionalEventNames) {
*/
export function EventsOffAll() {
const eventNames = Object.keys(eventListeners);
for (let i = 0; i !== eventNames.length; i++) {
removeListener(eventNames[i]);
}
eventNames.forEach(eventName => {
removeListener(eventName)
})
}
/**

View file

@ -9,9 +9,18 @@ The electron alternative for Go
*/
/* jshint esversion: 9 */
import * as Log from './log';
import {eventListeners, EventsEmit, EventsNotify, EventsOff, EventsOn, EventsOnce, EventsOnMultiple} from './events';
import {Call, Callback, callbacks} from './calls';
import {SetBindings} from "./bindings";
import {
eventListeners,
EventsEmit,
EventsNotify,
EventsOff,
EventsOffAll,
EventsOn,
EventsOnce,
EventsOnMultiple,
} from "./events";
import { Call, Callback, callbacks } from './calls';
import { SetBindings } from "./bindings";
import * as Window from "./window";
import * as Screen from "./screen";
import * as Browser from "./browser";
@ -48,6 +57,7 @@ window.runtime = {
EventsOnMultiple,
EventsEmit,
EventsOff,
EventsOffAll,
Environment,
Show,
Hide,
@ -88,12 +98,12 @@ if (!DEBUG) {
delete window.wailsbindings;
}
let dragTest = function (e) {
let dragTest = function(e) {
var val = window.getComputedStyle(e.target).getPropertyValue(window.wails.flags.cssDragProperty);
if (val) {
val = val.trim();
val = val.trim();
}
if (val !== window.wails.flags.cssDragValue) {
return false;
}
@ -111,12 +121,12 @@ let dragTest = function (e) {
return true;
};
window.wails.setCSSDragProperties = function (property, value) {
window.wails.setCSSDragProperties = function(property, value) {
window.wails.flags.cssDragProperty = property;
window.wails.flags.cssDragValue = value;
}
window.wails.setCSSDropProperties = function (property, value) {
window.wails.setCSSDropProperties = function(property, value) {
window.wails.flags.cssDropProperty = property;
window.wails.flags.cssDropValue = value;
}
@ -157,7 +167,7 @@ function setResize(cursor) {
window.wails.flags.resizeEdge = cursor;
}
window.addEventListener('mousemove', function (e) {
window.addEventListener('mousemove', function(e) {
if (window.wails.flags.shouldDrag) {
window.wails.flags.shouldDrag = false;
let mousePressed = e.buttons !== undefined ? e.buttons : e.which;
@ -195,7 +205,7 @@ window.addEventListener('mousemove', function (e) {
});
// Setup context menu hook
window.addEventListener('contextmenu', function (e) {
window.addEventListener('contextmenu', function(e) {
// always show the contextmenu in debug & dev
if (DEBUG) return;

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View file

@ -48,6 +48,10 @@ export function EventsOff(eventName, ...additionalEventNames) {
return window.runtime.EventsOff(eventName, ...additionalEventNames);
}
export function EventsOffAll() {
return window.runtime.EventsOffAll();
}
export function EventsOnce(eventName, callback) {
return EventsOnMultiple(eventName, callback, 1);
}