Skip to content

Commit cfadcb3

Browse files
committed
Mac OS: improve multi-line text support for button%
Related to #163
1 parent ebf4cba commit cfadcb3

File tree

4 files changed

+16
-7
lines changed

4 files changed

+16
-7
lines changed

gui-doc/scribblings/gui/button-class.scrbl

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Whenever a button is clicked by the user, the button's callback
1717
[parent (or/c (is-a?/c frame%) (is-a?/c dialog%)
1818
(is-a?/c panel%) (is-a?/c pane%))]
1919
[callback ((is-a?/c button%) (is-a?/c control-event%) . -> . any) (lambda (b e) (void))]
20-
[style (listof (or/c 'border 'deleted)) null]
20+
[style (listof (or/c 'border 'multi-line 'deleted)) null]
2121
[font (is-a?/c font%) normal-control-font]
2222
[enabled any/c #t]
2323
[vert-margin spacing-integer? 2]
@@ -59,9 +59,17 @@ The @racket[callback] procedure is called (with the event type
5959
If @racket[style] includes @racket['border], the button is drawn with
6060
a special border that indicates to the user that it is the default
6161
action button (see @method[top-level-window<%>
62-
on-traverse-char]). @DeletedStyleNote[@racket[style] @racket[parent]]{button}
62+
on-traverse-char]). If @racket[style] includes @racket['multi-line],
63+
the button is drawn in a way that can stretch vertically and accommodate
64+
multiple lines in a text label; currently, this style makes a difference only
65+
on Mac OS, and it is selected automatically when @racket[label] is a string
66+
that contains @racket[#\newline] or @racket[#\return].
67+
@DeletedStyleNote[@racket[style] @racket[parent]]{button}
6368

64-
@FontKWs[@racket[font]] @WindowKWs[@racket[enabled]] @SubareaKWs[] @AreaKWs[]}
69+
@FontKWs[@racket[font]] @WindowKWs[@racket[enabled]] @SubareaKWs[] @AreaKWs[]
70+
71+
@history[#:changed "1.47" @elem{Added the @racket['multi-line] style, and made it
72+
selected when @racket[label] contains @racket[#\return].}]}
6573

6674

6775
@defmethod[#:mode override

gui-lib/info.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,4 @@
3131

3232
(define pkg-authors '(mflatt robby))
3333

34-
(define version "1.46")
34+
(define version "1.47")

gui-lib/mred/private/mritem.rkt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@
243243
(check-label-string-or-bitmap-or-both cwho label)
244244
(check-container-parent cwho parent)
245245
(check-callback cwho callback)
246-
(check-style cwho #f '(border deleted) style)
246+
(check-style cwho #f '(border multi-line deleted) style)
247247
(check-font cwho font))
248248
(as-entry
249249
(lambda ()

gui-lib/mred/private/wx/cocoa/button.rkt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,9 @@
5353
(when button-type
5454
(tellv cocoa setButtonType: #:type _int button-type))
5555
(unless button-type
56-
(tellv cocoa setBezelStyle: #:type _int (if (or (not (string? label))
57-
(regexp-match? #rx"\n" label))
56+
(tellv cocoa setBezelStyle: #:type _int (if (or (memq 'multi-line style)
57+
(not (string? label))
58+
(regexp-match? #rx"[\n\r]" label))
5859
NSRegularSquareBezelStyle
5960
NSRoundedBezelStyle)))
6061
(cond

0 commit comments

Comments
 (0)