/ Published in: Haskell
This examples shows how to handle user-defined events in wxHaskell via menu events.
If the thread issues an event is not the main thread, use evtHandlerAddPendingEvent instead of evtHandlerProcessEvent.
Expand |
Embed | Plain Text
import EnableGUI -- from http://wxhaskell.sourceforge.net/download/EnableGUI.hs import Graphics.UI.WXCore hiding (Var) import Graphics.UI.WX hiding (Var, enter) import Data.Bits ((.&.), complement) myEventId = wxID_HIGHEST+1 -- the custom event ID -- the custom event is registered as a menu event createMyEvent = commandEventCreate wxEVT_COMMAND_MENU_SELECTED myEventId registerMyEvent win io = evtHandlerOnMenuCommand win myEventId io gui = do f <- frame [text := "custom event sample"] bt <- button f [text := "click to invoke a custom event"] set f [layout := column 1 [hfill (widget bt)]] set bt [on command := onClick f] where onClick f = do ev <- createMyEvent evtHandlerProcessEvent f ev main = enableGUI >> start gui
You need to login to post a comment.
