mirror of
https://github.com/lightpanda-io/browser.git
synced 2026-02-04 06:23:45 +00:00
EventManager: add hasListener
Not sure if this should be in `EventTarget` or `EventManager`, here goes nothing.
This commit is contained in:
@@ -197,6 +197,21 @@ pub fn dispatchWithFunction(self: *EventManager, target: *EventTarget, event: *E
|
||||
try self.dispatchAll(list, target, event, &was_dispatched);
|
||||
}
|
||||
|
||||
/// Returns true if there's at least 1 listener for given `event_type`.
|
||||
pub fn hasListener(self: *const EventManager, event_target: *const EventTarget, typ: []const u8) bool {
|
||||
const list = self.lookup.get(@intFromPtr(event_target)) orelse return false;
|
||||
|
||||
var current_node = list.first;
|
||||
while (current_node) |node| : (current_node = node.next) {
|
||||
const listener: *const Listener = @alignCast(@fieldParentPtr("node", node));
|
||||
if (listener.typ.eqlSlice(typ)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
fn dispatchNode(self: *EventManager, target: *Node, event: *Event, was_handled: *bool) !void {
|
||||
const ShadowRoot = @import("webapi/ShadowRoot.zig");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user