expected: (or/c (is-a?/c menu%) (is-a?/c popup-menu%))
given: 10
The [documentation][1] actually states that the method should expect a
menu-item%, not a menu%
(send a-frame:standard-menus edit-menu:between-clear-and-select-all
menu)
→ void?
menu : (is-a?/c menu-item%)
Also, I’m still having trouble getting it to work.
When I run the follow code, the program executes, but no sub-menu is
added to Edit Menu.
\#lang racket/gui
(require framework)
(define ext-frame%
(frame:standard-menus-mixin
(frame:status-line-mixin frame:basic%)))
(define (patch-menu parent-frame)
(new menu%
[parent (list-ref (send (send parent-frame get-menu-bar)
get-items) 1)]
[label "Patch”]))
(define shc-frame%
(class ext-frame%
(super-new)
(define/override (edit-menu:create-clear?) #f)
(define/override (edit-menu:between-select-all-and-find _)
(super edit-menu:between-select-all-and-find (patch-menu
this)))))
(define test-frame (new shc-frame%
[label "TEST!"]
[height 200]
[width 200]))
(send test-frame show #t)
Thanks so much for the quick replies and for bearing with me.
-Bruce
[1]:https://docs.racket-lang.org/framework/Frame.html?q=framework
On 22 Apr 2016, at 8:52, Matthias Felleisen wrote:
If you modify your sample code like this,
#lang racket/gui
(require framework)
(define ext-frame%
(frame:standard-menus-mixin
(frame:status-line-mixin frame:basic%)))
(define shc-frame%
(class ext-frame%
(super-new)
(define/override (edit-menu:create-clear?) #f)
(define/override (edit-menu:between-select-all-and-find _)
(super edit-menu:between-select-all-and-find 10)
(new menu-item%
[parent (list-ref (send (send this get-menu-bar) get-items)
1)]
[label "Patch"]
[callback (lambda (menu event)
(send this show #t))])))) ; The callback is
just a placeholder for now.
(define test-frame (new shc-frame%
[label "TEST!"]
[height 200]
[width 200]))
you find out that (1) the method really takes one argument and (2)
that it expects a menu:
expected: (or/c (is-a?/c menu%) (is-a?/c popup-menu%))
given: 10
What this means is that someone added contracts to the method as it
was implemented
and that the docs are wrong.
-- Matthias
On Apr 22, 2016, at 8:46 AM, Bruce Steinberg <[email protected]>
wrote:
I'm having trouble with overriding one of framework's methods to add
a menu item. Here's what I'm currently doing:
#lang racket/gui
(require framework)
(define ext-frame%
(frame:standard-menus-mixin
(frame:status-line-mixin frame:basic%)))
(define shc-frame%
(class ext-frame%
(super-new)
(define/override (edit-menu:create-clear?) #f)
(define/override (edit-menu:between-select-all-and-find)
(new menu-item%
[parent (list-ref (send (send this get-menu-bar)
get-items) 1)]
[label "Patch"]
[callback (lambda (menu event)
(send this show #t))])))) ; The callback
is just a placeholder for now.
(define test-frame (new shc-frame%
[label "TEST!"]
[height 200]
[width 200]))
When I run the program I get the following error:
edit-menu:between-select-all-and-find method in shc-frame%: arity
mismatch;
the expected number of arguments does not match the given number
expected: 0
given: 1
arguments...:
(object:...ork/private/menu.rkt:33:4 ...)
Sorry if I'm missing something basic. I'm fairly new to programming.
Thanks so much.
-Bruce
--
You received this message because you are subscribed to the Google
Groups "Racket Users" group.
To unsubscribe from this group and stop receiving emails from it,
send an email to [email protected].
For more options, visit https://groups.google.com/d/optout.
--
You received this message because you are subscribed to the Google Groups "Racket
Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.