Be wary that the default-shortcut-prefix might be

duplicated in a menu item prefix
This commit is contained in:
Robby Findler 2013-12-27 17:33:24 -06:00
parent ec75e9ae08
commit c12a6bea0e
2 changed files with 41 additions and 21 deletions

View File

@ -687,14 +687,15 @@
(send item enable (and frame (> (length (send frame get-tabs)) 1)))))]) (send item enable (and frame (> (length (send frame get-tabs)) 1)))))])
(group:add-to-windows-menu (group:add-to-windows-menu
(λ (windows-menu) (λ (windows-menu)
(define shortcut? (not (equal? 'shift (get-default-shortcut-prefix))))
(define sprefix (if (eq? (system-type) 'windows) (define sprefix (if (eq? (system-type) 'windows)
(cons 'shift (get-default-shortcut-prefix)) (cons 'shift (get-default-shortcut-prefix))
(get-default-shortcut-prefix))) (get-default-shortcut-prefix)))
(new menu-item% (new menu-item%
[parent windows-menu] [parent windows-menu]
[label (string-constant prev-tab)] [label (string-constant prev-tab)]
[shortcut #\[] [shortcut (and shortcut? #\[)]
[shortcut-prefix sprefix] [shortcut-prefix (if shortcut? sprefix (get-default-shortcut-prefix))]
[demand-callback dc] [demand-callback dc]
[callback (λ (item _) [callback (λ (item _)
(let ([frame (find-frame item)]) (let ([frame (find-frame item)])
@ -711,18 +712,21 @@
(when frame (when frame
(send frame next-tab))))]) (send frame next-tab))))])
(define mprefix (case (system-type) (define-values (mprefix use-shortcut?)
(case (system-type)
[(windows unix) [(windows unix)
(list* 'alt 'shift (get-default-shortcut-prefix))] (if (equal? (get-default-shortcut-prefix) 'ctl)
(values (list* 'alt 'shift (get-default-shortcut-prefix)) #f)
(values (get-default-shortcut-prefix) #t))]
[(macosx) [(macosx)
(list* 'option (get-default-shortcut-prefix))])) (values (cons 'option (get-default-shortcut-prefix)) #t)]))
(new menu-item% (new menu-item%
[parent windows-menu] [parent windows-menu]
[label (string-constant move-current-tab-right)] [label (string-constant move-current-tab-right)]
[demand-callback dc] [demand-callback dc]
[shortcut-prefix mprefix] [shortcut-prefix mprefix]
[shortcut #\]] [shortcut (and use-shortcut? #\])]
[callback (λ (item _) [callback (λ (item _)
(let ([frame (find-frame item)]) (let ([frame (find-frame item)])
(when frame (when frame
@ -733,7 +737,7 @@
[label (string-constant move-current-tab-left)] [label (string-constant move-current-tab-left)]
[demand-callback dc] [demand-callback dc]
[shortcut-prefix mprefix] [shortcut-prefix mprefix]
[shortcut #\[] [shortcut (and shortcut? #\[)]
[callback (λ (item _) [callback (λ (item _)
(let ([frame (find-frame item)]) (let ([frame (find-frame item)])
(when frame (when frame

View File

@ -3370,8 +3370,12 @@
(λ (mi) (send mi set-label (if (send resizable-panel get-vertical?) (λ (mi) (send mi set-label (if (send resizable-panel get-vertical?)
(string-constant use-horizontal-layout) (string-constant use-horizontal-layout)
(string-constant use-vertical-layout))))] (string-constant use-vertical-layout))))]
[shortcut #\l] [shortcut (if (member 'shift (get-default-shortcut-prefix))
[shortcut-prefix (cons 'shift (get-default-shortcut-prefix))])]) #f
#\l)]
[shortcut-prefix (if (member 'shift (get-default-shortcut-prefix))
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix)))])])
(set-show-menu-sort-key layout-item 103)) (set-show-menu-sort-key layout-item 103))
(let ([overview-menu-item (let ([overview-menu-item
@ -3514,10 +3518,16 @@
(demand-callback (λ (item) (split-demand item))))] (demand-callback (λ (item) (split-demand item))))]
[collapse [collapse
(new menu:can-restore-menu-item% (new menu:can-restore-menu-item%
(shortcut (if (eq? (system-type) 'macosx) #f #\m)) (shortcut (if (or (equal? (system-type) 'macosx)
(shortcut-prefix (if (eq? (system-type) 'macosx) (member 'shift (get-default-shortcut-prefix)))
(get-default-shortcut-prefix) #f
(cons 'shift (get-default-shortcut-prefix)))) #\m))
(shortcut-prefix (cond
[(or (equal? (system-type) 'macosx)
(member 'shift (get-default-shortcut-prefix)))
(get-default-shortcut-prefix)]
[else
(cons 'shift (get-default-shortcut-prefix))]))
(label (string-constant collapse-menu-item-label)) (label (string-constant collapse-menu-item-label))
(parent (get-show-menu)) (parent (get-show-menu))
(callback (λ (x y) (collapse))) (callback (λ (x y) (collapse)))
@ -3758,8 +3768,10 @@
(lambda (file-menu) (lambda (file-menu)
(new menu:can-restore-menu-item% (new menu:can-restore-menu-item%
[label (string-constant open-collection-path)] [label (string-constant open-collection-path)]
[shortcut #\o] [shortcut (if (member 'shift (get-default-shortcut-prefix)) #f #\o)]
[shortcut-prefix (cons 'shift (get-default-shortcut-prefix))] [shortcut-prefix (if (member 'shift (get-default-shortcut-prefix))
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix)))]
[parent file-menu] [parent file-menu]
[callback [callback
(λ (x y) (λ (x y)
@ -3862,8 +3874,12 @@
label) label)
(new menu:can-restore-checkable-menu-item% (new menu:can-restore-checkable-menu-item%
[label label] [label label]
[shortcut shortcut] [shortcut (if (member 'shift (get-default-shortcut-prefix))
[shortcut-prefix (cons 'shift (get-default-shortcut-prefix))] #f
shortcut)]
[shortcut-prefix (if (member 'shift (get-default-shortcut-prefix))
(get-default-shortcut-prefix)
(cons 'shift (get-default-shortcut-prefix)))]
[parent edit-menu] [parent edit-menu]
[demand-callback [demand-callback
(λ (item) (λ (item)