fix: cancel when clicking outside of a palette instead of activating the current item
This commit is contained in:
parent
0eec33c35e
commit
f61c6c7f87
1 changed files with 8 additions and 1 deletions
|
@ -51,7 +51,10 @@ pub fn Create(options: type) type {
|
||||||
const self: *Self = try allocator.create(Self);
|
const self: *Self = try allocator.create(Self);
|
||||||
self.* = .{
|
self.* = .{
|
||||||
.allocator = allocator,
|
.allocator = allocator,
|
||||||
.modal = try ModalBackground.create(*Self, allocator, tui.current().mainview, .{ .ctx = self }),
|
.modal = try ModalBackground.create(*Self, allocator, tui.current().mainview, .{
|
||||||
|
.ctx = self,
|
||||||
|
.on_click = mouse_palette_menu_cancel,
|
||||||
|
}),
|
||||||
.menu = try Menu.create(*Self, allocator, tui.current().mainview, .{
|
.menu = try Menu.create(*Self, allocator, tui.current().mainview, .{
|
||||||
.ctx = self,
|
.ctx = self,
|
||||||
.on_render = if (@hasDecl(options, "on_render_menu")) options.on_render_menu else on_render_menu,
|
.on_render = if (@hasDecl(options, "on_render_menu")) options.on_render_menu else on_render_menu,
|
||||||
|
@ -201,6 +204,10 @@ pub fn Create(options: type) type {
|
||||||
self.start_query(0) catch {};
|
self.start_query(0) catch {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn mouse_palette_menu_cancel(self: *Self, _: *ModalBackground.State(*Self)) void {
|
||||||
|
self.cmd("palette_menu_cancel", .{}) catch {};
|
||||||
|
}
|
||||||
|
|
||||||
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
pub fn receive(self: *Self, _: tp.pid_ref, m: tp.message) error{Exit}!bool {
|
||||||
var text: []const u8 = undefined;
|
var text: []const u8 = undefined;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue