Chris Lemmer-Webber
unread,Jul 13, 2021, 1:04:23 PM7/13/21Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to racket...@googlegroups.com
Hello,
I'm using the mrlib/hierlist in a GUI I have, and I wanted to add a
right-click menu. I'm trying to do that, but I can't find an
appropriate place to notice the event.
I noticed I can set up a clickback, but it doesn't seem aware of whether
it's a right or left button click. I have the following code:
(define (set-text-mixin room room-channel room-ui-manager)
(mixin (hierarchical-list-item<%>)
((interface () set-text))
(inherit get-editor)
(super-new)
; set-text: this sets the label of the item
(define/public (set-text str)
(define t (get-editor)) ; a text% object
(send t erase)
;; We need a way to capture right-clicks, so we're creating our
;; own snip here
(define str-snip
(new (class string-snip%
(super-new)
(define/override (on-event dc x y editorx editory ev)
;; pk is a print debug tool, should print this out
(pk 'on-event dc x y editorx editory ev)
(super on-event dc x y editorx editory ev)))))
(send str-snip insert str (string-length str) 0)
(send t insert str-snip))
(define/public (get-room)
room)
(define/public (get-room-channel)
room-channel)
(define/public (install-as-current)
($ room-ui-manager 'install-as-current))))
This does set the text of the item appropriately, and I figured trying
to override the string-snip, but the pk (print debug) inside of the
overridden on-event never gets called. Not sure why. Does on-event
never get passed through to the snips inside of heirarchical list menu
items?
Is there a better, simpler solution?