add menu shortcuts

master
Matthew Butterick 5 years ago
parent 207b1c2225
commit c450d45984

@ -50,17 +50,20 @@
[stretchable-width #f] [stretchable-width #f]
[callback (λ (tf evt) (update-text-field! tf param))])) [callback (λ (tf evt) (update-text-field! tf param))]))
(let ([optional-letter-panel (new horizontal-panel% (define optional-letter-panel (new horizontal-panel%
[parent window] [parent window]
[horiz-margin 6] [horiz-margin 6]
[alignment '(left top)] [alignment '(left top)]
[stretchable-height #false])]) [stretchable-height #false]))
(define tf-optional (define tf-optional
(make-text-field current-optional "optional letters" optional-letter-panel)) (make-text-field current-optional "optional letters" optional-letter-panel))
(define ((tf-optional-button-callback str) button evt) (define ((tf-optional-button-callback str) button evt)
(send tf-optional set-value str) (send tf-optional set-value str)
(update-text-field! tf-optional current-optional)) (update-text-field! tf-optional current-optional))
(for ([label-str '("clear" "a-z" "etaoinshrdluw")]
(match-define (list button-clear button-az button-common)
(for/list ([label-str '("clear" "a-z" "etaoinshrdluw")]
[str '("" "abcdefghijklmnopqrstuvwxyz" "etaoinshrdluw")]) [str '("" "abcdefghijklmnopqrstuvwxyz" "etaoinshrdluw")])
(new button% (new button%
[label label-str] [label label-str]
@ -212,15 +215,23 @@
(current-word-count new-count)) (current-word-count new-count))
(define menu-item-more-words (define menu-item-more-words
(make-menu-item "More" #\= (λ (thing evt) (make-menu-item "More words" #\= (λ (thing evt)
(change-word-count 25) (change-word-count 25)
(refresh-wordbox)))) (refresh-wordbox))))
(define menu-item-fewer-words (define menu-item-fewer-words
(make-menu-item "Fewer" #\- (λ (thing evt) (make-menu-item "Fewer words" #\- (λ (thing evt)
(change-word-count -25) (change-word-count -25)
(refresh-wordbox)))) (refresh-wordbox))))
; (list button-clear button-az button-common)
(define menu-item-clear
(make-menu-item "Clear letters" #\1 (λ (thing evt) (send button-clear command evt))))
(define menu-item-az
(make-menu-item "Use a-z" #\2 (λ (thing evt) (send button-az command evt))))
(define menu-item-common
(make-menu-item "Use etaoin" #\3 (λ (thing evt) (send button-common command evt))))
(refresh-wordbox) (refresh-wordbox)
(send window show #t) (send window show #t)

Loading…
Cancel
Save