如何使用 Racket GUI 插件将输入文本包装在文本字段中
How to wrap input text in text-field using the Racket GUI plugin
只需要一个包装输入的文本字段% 的基本示例
(define blogPost%
(class horizontal-panel%
(super-new)
(define (callback button event)
(define title-new-value (send titleoutput get-value))
(define new-value (send output get-value))
(save title-new-value new-value))
;;(display title-new-value)
;;(display new-value))
(define button (new button% (label "Submit")
(vert-margin 0)
(parent this)
(callback callback)))
(define titleoutput (new text-field% (label " title")
(min-height 20)
(min-width 200)
(parent this)))
(define output (new text-field% (label "blog")
(min-height 450)
(min-width 400)
(stretchable-width 300)
(vert-margin 0)
(parent this)))
))
(define f (new frame% (label "prism blog post GUI") (min-width 400) (min-height 500)))
(define tib (new blogPost%
(parent f)))
(send f show #t)
还有更多内容,基本上它将用户的输入保存到我们计划访问并打印到屏幕的数据库中。然而,用户在文本字段中输入时,只是在一行中水平输入,它从不自动换行,输入按钮也不会换行。这个问题可以解决吗?
要允许在文本字段中进行多行输入,您需要将 [style '(multiple)]
添加到初始化参数中,如下所示:
(define output (new text-field% [label "blog"]
[style '(multiple)]
[min-height 450]
[min-width 400]
[stretchable-width 300]
[vert-margin 0]
[parent this]))
然后文本字段允许换行,当一行太长时它会换行。
这方面的文档是 here。在那里,它说:
There are two text field styles:
A single line of text is visible, and a special control event is generated when the user presses Return or Enter (when the text field has the focus) and the event is not handled by the text field’s frame or dialog (see on-traverse-char
in top-level-window<%>
).
Multiple lines of text are visible, and Enter is not handled specially.
稍后,它指定样式参数是一个符号列表并表示:
The style must contain exactly one of 'single
or 'multiple
; the former specifies a single-line field and the latter specifies a multiple-line field.
只需要一个包装输入的文本字段% 的基本示例
(define blogPost%
(class horizontal-panel%
(super-new)
(define (callback button event)
(define title-new-value (send titleoutput get-value))
(define new-value (send output get-value))
(save title-new-value new-value))
;;(display title-new-value)
;;(display new-value))
(define button (new button% (label "Submit")
(vert-margin 0)
(parent this)
(callback callback)))
(define titleoutput (new text-field% (label " title")
(min-height 20)
(min-width 200)
(parent this)))
(define output (new text-field% (label "blog")
(min-height 450)
(min-width 400)
(stretchable-width 300)
(vert-margin 0)
(parent this)))
))
(define f (new frame% (label "prism blog post GUI") (min-width 400) (min-height 500)))
(define tib (new blogPost%
(parent f)))
(send f show #t)
还有更多内容,基本上它将用户的输入保存到我们计划访问并打印到屏幕的数据库中。然而,用户在文本字段中输入时,只是在一行中水平输入,它从不自动换行,输入按钮也不会换行。这个问题可以解决吗?
要允许在文本字段中进行多行输入,您需要将 [style '(multiple)]
添加到初始化参数中,如下所示:
(define output (new text-field% [label "blog"]
[style '(multiple)]
[min-height 450]
[min-width 400]
[stretchable-width 300]
[vert-margin 0]
[parent this]))
然后文本字段允许换行,当一行太长时它会换行。
这方面的文档是 here。在那里,它说:
There are two text field styles:
A single line of text is visible, and a special control event is generated when the user presses Return or Enter (when the text field has the focus) and the event is not handled by the text field’s frame or dialog (see
on-traverse-char
intop-level-window<%>
).Multiple lines of text are visible, and Enter is not handled specially.
稍后,它指定样式参数是一个符号列表并表示:
The style must contain exactly one of
'single
or'multiple
; the former specifies a single-line field and the latter specifies a multiple-line field.