DVUI

addEventText

Add an event that represents text being typed. This is distinct from key up/down because the text could come from an IME (Input Method Editor).

This can be called outside begin/end. You should add all the events for a frame either before begin() or just after begin() and before calling normal dvui widgets. end() clears the event list.

Parameters

#
self:*Self
*Self
opts:AddEventTextOptions
AddEventTextOptions

Source

Implementation

#
pub fn addEventText(self: *Self, opts: AddEventTextOptions) std.mem.Allocator.Error!bool {
    self.positionMouseEventRemove();

    self.event_num += 1;
    try self.events.append(self.arena(), Event{
        .num = self.event_num,
        .evt = .{
            .text = .{ .action = .{ .value = .{
                .txt = try self.arena().dupe(u8, opts.text),
                .selected = opts.selected,
            } } },
        },
        .target_windowId = self.subwindows.focused_id,
        .target_widgetId = opts.target_id orelse if (self.subwindows.focused()) |sw| sw.focused_widget_id else null,
    });

    const ret = (self.data().id != self.subwindows.focused_id);
    try self.positionMouseEventAdd();
    return ret;
}