File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,7 +82,6 @@ fn main_view(mut window gui.Window) gui.View {
8282 // ---------------------------------------------------------
8383 on_click: fn (_ voidptr , mut e gui.Event, mut w gui.Window) {
8484 mut app := w.state[ContextMenuApp]()
85- println (u8 (e.mouse_button))
8685 if e.mouse_button == .right {
8786 app.show_context_menu = true
8887 w.set_id_focus (id_focus_context_menu)
Original file line number Diff line number Diff line change @@ -72,7 +72,7 @@ pub fn button(cfg ButtonCfg) View {
7272 sizing: cfg.sizing
7373 tooltip: cfg.tooltip
7474 cfg: & cfg
75- on_click: cfg.on_click
75+ on_click: cfg.left_click ()
7676 on_char: cfg.on_char_button
7777 amend_layout: cfg.amend_layout
7878 on_hover: cfg.on_hover
@@ -92,6 +92,17 @@ pub fn button(cfg ButtonCfg) View {
9292 )
9393}
9494
95+ fn (cfg &ButtonCfg) left_click () fn (& ButtonCfg, mut Event, mut Window) {
96+ if cfg.on_click == unsafe { nil } {
97+ return cfg.on_click
98+ }
99+ return fn [cfg] (_ & ButtonCfg, mut e Event, mut w Window) {
100+ if e.mouse_button == .left {
101+ cfg.on_click (cfg, mut e, mut w)
102+ }
103+ }
104+ }
105+
95106fn (cfg &ButtonCfg) on_char_button (_ & ButtonCfg, mut e Event, mut w Window) {
96107 if e.char_code == ` ` && cfg.on_click != unsafe { nil } {
97108 cfg.on_click (cfg, mut e, mut w)
You can’t perform that action at this time.
0 commit comments