Respond to key events globally

50 Views Asked by At

How do I respond to keyboard events regardless of what widget currently has the focus? For example, the following program only responds to a keyboard event with a "Key pressed" message when the textCtrl isn't being focused on, which isn't what I want.

import Graphics.UI.WX

main = start $ do
    window <- frame []
    c1 <- textCtrl window []
    c2 <- panel window []

    set window [layout := minsize (sz 100 100) $ column 10 [widget c1, widget c2]]

    set c2 [on keyboard := (\_ -> print "Key pressed")]
0

There are 0 best solutions below