0

当我启动我的应用程序时,我想将焦点设置在某个按钮上。目前我需要点击tab一次才能使按钮集中。

这些wxwidgets文件提到了一种似乎在 ? 中不可用的SetFocus方法(链接wxhaskell) ?

然后我找到了MoveBeforeInTabOrder链接),但同样,我没有在wxhaskell.

wxhaskell 提到它的维护者在 2009 年是一个“相当完整的 GUI 绑定”,所以我只是在这里遗漏了一些东西还是运气不好?

这是我的最小示例:

module Main where

import Graphics.UI.WX
import Graphics.UI.WXCore

main :: IO ()
main = start hello

hello :: IO ()
hello = do
  f <- frame []
  test <- button f [ text := "button" ]
  set f [ layout := widget test ]
4

1 回答 1

1

wx 库有一个focusOn功能可以让您专注于控件。

它是wxcore 的windowSetFocus. 该类型有点误导:它说Window a,但它适用于按钮,因为它们也是 windows

以下作品(注意我只添加了最后一行):

module Main where

import Graphics.UI.WX
import Graphics.UI.WXCore

main :: IO ()
main = start hello

hello :: IO ()
hello = do
  f <- frame []
  test <- button f [ text := "button" ]
  set f [ layout := widget test ]
  focusOn test                          -- Here!
于 2016-01-09T19:06:46.803 回答