[英]How do I focus a widget?
當我啟動應用程序時,我想將焦點設置在某個按鈕上。 目前,我需要按一下tab
鍵才能使按鈕聚焦。
wxwidgets
文檔提到了SetFocus
方法( 鏈接 ),它在wxhaskell
似乎不可用?
然后我找到了MoveBeforeInTabOrder
( link ),但再次在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 ]
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!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.