addEventFocus
Focus the widget under pt, without moving mouse_pt.
Parameters
- self:*Self
- *Self
- opts:AddEventFocusOptions
- AddEventFocusOptions
Source
Implementation
pub fn addEventFocus(self: *Self, opts: AddEventFocusOptions) std.mem.Allocator.Error!bool {
self.positionMouseEventRemove();
const target_id = opts.target_id orelse if (self.capture) |cap| cap.id else null;
const winId = self.subwindows.windowFor(opts.pt);
// normally the focus event is what focuses windows, but since the
// base window is instantiated before events are added, it has to
// do any event processing as the events come in, right now
if (winId == self.data().id) {
// focus the window here so any more key events get routed
// properly
self.focusSubwindow(self.data().id, null);
}
// add focus event
self.event_num += 1;
try self.events.append(self.arena(), Event{
.num = self.event_num,
.target_widgetId = target_id,
.evt = .{
.mouse = .{
.action = .focus,
.button = opts.button,
.mod = self.modifiers,
.p = opts.pt,
.floating_win = winId,
},
},
});
try self.positionMouseEventAdd();
return (self.data().id != winId);
}