This commit is contained in:
2026-02-19 11:19:04 +01:00
parent 72652a809b
commit 4fbb9c53ff
5 changed files with 36 additions and 2 deletions

View File

@@ -86,7 +86,6 @@
(write-json (menu->hash menu) o) (write-json (menu->hash menu) o)
(get-output-string o))) (get-output-string o)))
(define (find-menu-item menu id) (define (find-menu-item menu id)
(let ((items (ww-menu-items menu))) (let ((items (ww-menu-items menu)))
(letrec ((f (λ (items) (letrec ((f (λ (items)

View File

@@ -12,6 +12,7 @@
gregor-utils gregor-utils
net/sendurl net/sendurl
racket/path racket/path
xml
) )
(provide ww-element% (provide ww-element%
@@ -606,6 +607,10 @@
(define/public (connect-menu! id cb) (define/public (connect-menu! id cb)
(hash-set! menu-cbs id cb)) (hash-set! menu-cbs id cb))
(define/public (popup-menu menu-def)
(ww-popup-menu win-id menu-def)
)
; files and directories ; files and directories
(define/public (file-open caption base-dir filters) (define/public (file-open caption base-dir filters)
(let ((r (ww-file-open win-id caption base-dir filters))) (let ((r (ww-file-open win-id caption base-dir filters)))

View File

@@ -42,6 +42,7 @@
ww-set-icon ww-set-icon
ww-set-menu ww-set-menu
ww-popup-menu
ww-set-html-file ww-set-html-file
ww-set-url ww-set-url
@@ -805,7 +806,12 @@
(def-cmd ww-set-menu (def-cmd ww-set-menu
set-menu ((win-id ww-win?) set-menu ((win-id ww-win?)
(menu is-menu?)) [] -> void) (menu is-menu?)) [] -> void)
;; Popup a menu
(def-cmd ww-popup-menu
popup-menu ((win-id ww-win?)
(menu is-menu?)) [] -> void)
(define (new-handle) (define (new-handle)
#t) #t)

View File

@@ -492,6 +492,12 @@ Associate a callback @racket[cb] with a menu item id. When the menu
item is activated, the callback is called. item is activated, the callback is called.
} }
@defmethod[(popup-menu [menu-def is-menu?]) void?]{
Pops up a contextmenu at the current cursor position.
The menu is created using a structure created with the helpers from
@racket["menu.rkt"].}
@bold{HTML and navigation} @bold{HTML and navigation}
@defmethod[(set-icon! [icn (or/c path? string?)]) void?]{ @defmethod[(set-icon! [icn (or/c path? string?)]) void?]{

View File

@@ -370,6 +370,24 @@ The @racket[menu] value is a menu structure as defined in
@racket["menu.rkt"]. @racket["menu.rkt"].
} }
@defproc[(ww-popup-menu [win-id ww-win?]
[menu is-menu?])
void?]{
Pops up a (context) menu at the current cursor position:
@racketblock[
(def-cmd ww-popup-menu
set-menu ((win-id ww-win?)
(menu is-menu?)) [] -> void)
]
The @racket[menu] value is a menu structure as defined in
@racket["menu.rkt"].
}
@defproc[(ww-set-show-state [win-id ww-win?] @defproc[(ww-set-show-state [win-id ww-win?]
[state symbol?]) [state symbol?])
void?]{ void?]{