Hide extra separator lines between empty menu item

2019-08-15 00:44发布

问题:

Separator lines still appear after hiding menu-items from this link => Can't hide "Preferences" item in edit-menu

I have searched in racket documentation and found only adding new separator menu item. https://docs.racket-lang.org/gui/separator-menu-item_.html Is it possible to hide these extra lines between empty menu items?

回答1:

Separator lines are created in the "between" methods. Those are removed by using void.

#lang racket/gui
(require framework)

(define menu-super-frame% 
  (frame:standard-menus-mixin   
   frame:basic%))

(define menu-frame%
  (class menu-super-frame%
    (inherit get-file-menu set-icon)

    (define/override (edit-menu:create-undo?) #t)    
    (define/override (edit-menu:create-redo?) #t)

    ;; hiding items in edit menu
    (define/override (edit-menu:create-cut?) #f)
    (define/override (edit-menu:create-copy?) #f)
    (define/override (edit-menu:create-paste?) #f)
    (define/override (edit-menu:create-clear?) #f)
    (define/override (edit-menu:create-select-all?) #f)
    (define/override (edit-menu:create-preferences?) #f)

    ;; remove separator lines
    (define/override (edit-menu:between-redo-and-cut edit-menu) (void)) 
    (define/override (edit-menu:between-select-all-and-find edit-menu) (void))
    (define/override (edit-menu:between-find-and-preferences edit-menu) (void))

    (super-new)))

(define top-frame 
  (new menu-frame%
       [label "Main Window"]
       [width 200]
       [height 200]
       [alignment (list 'left 'top)]))

(send top-frame show #t)

reference answer