deinit
Parameters
- self:*FloatingMenuWidget
- *FloatingMenuWidget
Source
Implementation
pub fn deinit(self: *FloatingMenuWidget) void {
defer if (dvui.widgetIsAllocated(self)) dvui.widgetFree(self);
defer self.* = undefined;
const evts = dvui.events();
const rs = self.data().rectScale();
for (evts) |*e| {
if (!dvui.eventMatch(e, .{ .id = self.data().id, .r = rs.r, .cleanup = true }))
continue;
if (e.evt == .mouse) {
if (e.evt.mouse.action == .focus) {
// unhandled click, clear focus
e.handle(@src(), self.data());
dvui.focusWidget(null, null, null);
}
} else if (e.evt == .key) {
// catch any tabs that weren't handled by widgets
if (e.evt.key.action == .down and e.evt.key.matchBind("next_widget")) {
e.handle(@src(), self.data());
dvui.tabIndexNext(e.num);
}
if (e.evt.key.action == .down and e.evt.key.matchBind("prev_widget")) {
e.handle(@src(), self.data());
dvui.tabIndexPrev(e.num);
}
}
}
if (!self.have_popup_child and !self.chainFocused(true)) {
// if a popup chain is open and the user focuses a different window
// (not the parent of the popups), then we want to close the popups
// only the last popup can do the check, you can't query the focus
// status of children, only parents
self.menu.close_chain(.unintentional);
dvui.refresh(null, @src(), self.data().id);
}
self.menu.deinit();
self.scroll.deinit();
self.scaler.deinit();
// in case no children ever show up, this will provide a visual indication
// that there is an empty floating menu
self.data().minSizeMax(self.data().options.padSize(.{ .w = 20, .h = 20 }));
self.data().minSizeSetAndRefresh();
// outside normal layout, don't call minSizeForChild or self.data().minSizeReportToParent();
_ = currentSet(self.parent_fmw);
dvui.parentReset(self.data().id, self.data().parent);
dvui.currentWindow().last_focused_id_this_frame = self.prev_last_focus;
// standard subwindow stuff
{
_ = dvui.ScrollContainerWidget.scrollSet(self.prev_scroll);
_ = dvui.subwindowCurrentSet(self.prev_windowInfo.id, self.prev_windowInfo.rect);
dvui.clipSet(self.prevClip);
self.render_ftb.deinit();
}
}