Hide extra separator lines between empty menu item

2019-08-15 00:20发布

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

enter image description here

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条回答
成全新的幸福
2楼-- · 2019-08-15 00:48

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

Separator lines are disappeared.

#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

查看更多
登录 后发表回答