建议弹出菜单 drracket
我正在使用 Racket 图形工具包,我正在尝试显示建议弹出菜单。
我有一个可用字符串列表可供选择,我想在您在文本字段中写入时在弹出菜单中显示它们。
我已设法向它们展示,但您必须重新选择文本字段才能继续写入。每次您选择文本字段时,弹出菜单就会消失。
这可能吗?如果是这样我怎样才能实现这个目标?
这是一个小例子来更好地解释我自己:
(define (prueba)
(let* ((ventana (new frame% (label "")))
(sugerencia (new popup-menu%))
(texto (new text-field% (label "prueba")(parent ventana)
(callback (lambda (t e)
(new menu-item% (label (send t get-value))(parent sugerencia)
(callback (lambda (i e) (void))))
(send ventana popup-menu sugerencia (+ 50 (send t get-x)) (+(send t get-height)(send t get-y))))))))
(send ventana show #t)))
im using Racket graphical toolkit and i'm trying to show a suggestion popup menu.
I have a list of available strings to select from and i want to show them in a popup menu as you write in a text-field.
I have managed to show them but you have to re select the text-field to continue writing. And every time you select the text-field the popup menu goes away.
Is this even possible? if so how can i achieve this?
here is a little example to explain my self better:
(define (prueba)
(let* ((ventana (new frame% (label "")))
(sugerencia (new popup-menu%))
(texto (new text-field% (label "prueba")(parent ventana)
(callback (lambda (t e)
(new menu-item% (label (send t get-value))(parent sugerencia)
(callback (lambda (i e) (void))))
(send ventana popup-menu sugerencia (+ 50 (send t get-x)) (+(send t get-height)(send t get-y))))))))
(send ventana show #t)))
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您不想在此处使用
popup-menu%
,这是通过右键单击获得的上下文菜单。相反,您应该只创建一个新窗口(或者可能只是一个新的frame%
),它将具有适当的回调以将建议插入到主frame%
中。You don't want to use a
popup-menu%
here, that's for the kind of contextual menus that you get from right-clicking. Instead, you should just create a new window (or maybe just a newframe%
which will have the appropriate callbacks to insert suggestions into the mainframe%
.