Racket GUI 工具包:如何嵌入 link
Racket GUI Toolkit: How to embed a link
假设我们有一个框架
(define my-frame (new frame% [parent #f] [label "test"]))
和一条消息,应该 link 到 google。
(new message%
[parent my-frame]
[label "https://www.google.com"])
(send my-frame show #t)
以上方法无效。如何在 Racket GUI 工具包中嵌入 link?
您可以使用该按钮,但我想那不是 link 那样,所以您不需要它,以下代码显示了如何使用编辑器 clickback 创建一个类似 link 的文本。
(require net/sendurl)
(define f (new frame% [parent #f]
[label "test"]
[width 300]
[height 300]))
(define editor (new text%))
(new editor-canvas% [parent f]
[editor editor])
(define t "https://www.google.com")
(send editor insert t)
(send editor set-clickback 0 (string-length t)
(λ (text start end)
(send-url t)))
(send* f
[show #t]
[center])
假设我们有一个框架
(define my-frame (new frame% [parent #f] [label "test"]))
和一条消息,应该 link 到 google。
(new message%
[parent my-frame]
[label "https://www.google.com"])
(send my-frame show #t)
以上方法无效。如何在 Racket GUI 工具包中嵌入 link?
您可以使用该按钮,但我想那不是 link 那样,所以您不需要它,以下代码显示了如何使用编辑器 clickback 创建一个类似 link 的文本。
(require net/sendurl)
(define f (new frame% [parent #f]
[label "test"]
[width 300]
[height 300]))
(define editor (new text%))
(new editor-canvas% [parent f]
[editor editor])
(define t "https://www.google.com")
(send editor insert t)
(send editor set-clickback 0 (string-length t)
(λ (text start end)
(send-url t)))
(send* f
[show #t]
[center])