addChoice
Parameters
- self:*SuggestionWidget
- *SuggestionWidget
Source
Implementation
pub fn addChoice(self: *SuggestionWidget) *MenuItemWidget {
self.drop_mi = @as(MenuItemWidget, undefined); // Must be a non-null value for the `.?` bellow
self.drop_mi.?.init(@src(), .{ .highlight_only = true }, .{
.role = .list_item,
.label = .{ .label_widget = .next },
.id_extra = self.drop_mi_index,
.expand = .horizontal,
.padding = .{},
});
self.drop_mi.?.processEvents();
if (self.drop_mi.?.data().id == dvui.focusedWidgetId()) {
self.selected_index = self.drop_mi_index;
}
if (self.selected_index == self.drop_mi_index) {
if (self.activate_selected) {
self.drop_mi.?.activated = true;
self.drop_mi.?.show_active = true;
} else {
self.drop_mi.?.highlight = true;
}
}
self.drop_mi.?.drawBackground();
self.drop_mi_index += 1;
return &self.drop_mi.?;
}