popup-menu
This commit is contained in:
@@ -75,6 +75,7 @@
|
||||
webview-base-url
|
||||
|
||||
webview-set-menu!
|
||||
webview-popup-menu!
|
||||
|
||||
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)
|
||||
(and (symbol? x)
|
||||
(or (eq? x 'error) (eq? x 'info) (eq? x 'debug) (eq? x 'warning))))
|
||||
|
||||
@@ -267,6 +267,9 @@
|
||||
(λ (el evt data)
|
||||
(callback))))
|
||||
|
||||
(define/public (disconnect-menu! id)
|
||||
(send this unbind! id 'menu-item-choosen))
|
||||
|
||||
(define/public (devtools)
|
||||
(webview-devtools wv)
|
||||
this)
|
||||
@@ -323,6 +326,26 @@
|
||||
(define/public (set-title! 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
|
||||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
Reference in New Issue
Block a user