popup-menu

This commit is contained in:
2026-04-07 23:42:08 +02:00
parent 798e8c8c43
commit 10a9f4b431
2 changed files with 33 additions and 0 deletions

View File

@@ -75,6 +75,7 @@
webview-base-url webview-base-url
webview-set-menu! webview-set-menu!
webview-popup-menu!
webview-set-innerHTML! webview-set-innerHTML!
@@ -537,6 +538,15 @@
) )
) )
(define/contract (webview-popup-menu! wv menu x y)
(-> wv-win? is-wv-menu? number? number? symbol?)
(let* ((json (wv-menu->json menu))
(js (string-append "window._web_wire_popup_menu(JSON.parse('"
json "', " (format "~a, ~a" x y)
");"))
)
(webview-run-js wv js)))
(define (loglevel? x) (define (loglevel? x)
(and (symbol? x) (and (symbol? x)
(or (eq? x 'error) (eq? x 'info) (eq? x 'debug) (eq? x 'warning)))) (or (eq? x 'error) (eq? x 'info) (eq? x 'debug) (eq? x 'warning))))

View File

@@ -266,6 +266,9 @@
(send this bind! (string->symbol (format "~a" id)) 'menu-item-choosen (send this bind! (string->symbol (format "~a" id)) 'menu-item-choosen
(λ (el evt data) (λ (el evt data)
(callback)))) (callback))))
(define/public (disconnect-menu! id)
(send this unbind! id 'menu-item-choosen))
(define/public (devtools) (define/public (devtools)
(webview-devtools wv) (webview-devtools wv)
@@ -323,6 +326,26 @@
(define/public (set-title! title) (define/public (set-title! title)
(webview-set-title! wv title)) (webview-set-title! wv title))
(define/public (popup-menu menu-def x y)
(webview-popup-menu wv menu-def x y)
(let* ((ids (list))
(clear-connections (λ ()
(for-each (λ (id)
(send this disconnect-menu! id))
ids))))
(menu-for-each menu-def
(λ (item)
(let ((cb (ww-menu-item-callback item))
(id (ww-menu-item-id item)))
(set! ids (cons id ids))
(send this connect-menu! id (λ ()
(clear-connections)
(cb))))))
(connect-menu! (ww-menu-id menu-def) (λ () (clear-connections)))
(set! ids (cons (ww-menu-id menu-def) ids))
)
)
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Files / Directories ;; Files / Directories
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;