From 4fbb9c53ff6fed505dbd824e64e8d383f8b5383f Mon Sep 17 00:00:00 2001 From: Hans Dijkema Date: Thu, 19 Feb 2026 11:19:04 +0100 Subject: [PATCH] - --- private/menu.rkt | 1 - private/web-racket.rkt | 5 +++++ private/web-wire.rkt | 8 +++++++- scribblings/web-racket.scrbl | 6 ++++++ scribblings/web-wire.scrbl | 18 ++++++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) diff --git a/private/menu.rkt b/private/menu.rkt index b2fa2d3..3941673 100644 --- a/private/menu.rkt +++ b/private/menu.rkt @@ -86,7 +86,6 @@ (write-json (menu->hash menu) o) (get-output-string o))) - (define (find-menu-item menu id) (let ((items (ww-menu-items menu))) (letrec ((f (λ (items) diff --git a/private/web-racket.rkt b/private/web-racket.rkt index f22b928..99bdaba 100644 --- a/private/web-racket.rkt +++ b/private/web-racket.rkt @@ -12,6 +12,7 @@ gregor-utils net/sendurl racket/path + xml ) (provide ww-element% @@ -606,6 +607,10 @@ (define/public (connect-menu! id cb) (hash-set! menu-cbs id cb)) + (define/public (popup-menu menu-def) + (ww-popup-menu win-id menu-def) + ) + ; files and directories (define/public (file-open caption base-dir filters) (let ((r (ww-file-open win-id caption base-dir filters))) diff --git a/private/web-wire.rkt b/private/web-wire.rkt index 7177fd1..25e9a65 100644 --- a/private/web-wire.rkt +++ b/private/web-wire.rkt @@ -42,6 +42,7 @@ ww-set-icon ww-set-menu + ww-popup-menu ww-set-html-file ww-set-url @@ -805,7 +806,12 @@ (def-cmd ww-set-menu set-menu ((win-id ww-win?) (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) #t) diff --git a/scribblings/web-racket.scrbl b/scribblings/web-racket.scrbl index a3183d8..290efa3 100644 --- a/scribblings/web-racket.scrbl +++ b/scribblings/web-racket.scrbl @@ -492,6 +492,12 @@ Associate a callback @racket[cb] with a menu item id. When the menu 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} @defmethod[(set-icon! [icn (or/c path? string?)]) void?]{ diff --git a/scribblings/web-wire.scrbl b/scribblings/web-wire.scrbl index 6ad1cf9..18a576a 100644 --- a/scribblings/web-wire.scrbl +++ b/scribblings/web-wire.scrbl @@ -370,6 +370,24 @@ The @racket[menu] value is a menu structure as defined in @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?] [state symbol?]) void?]{