Add keyPress.hs
This commit is contained in:
parent
62654e9cd1
commit
45e54a263e
1 changed files with 45 additions and 0 deletions
45
keyPress.hs
Normal file
45
keyPress.hs
Normal file
|
|
@ -0,0 +1,45 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings, OverloadedLabels, ImplicitParams #-}
|
||||||
|
|
||||||
|
import Control.Monad (void)
|
||||||
|
import System.Environment (getArgs, getProgName)
|
||||||
|
import Data.Text (unpack)
|
||||||
|
import Data.Int (Int32)
|
||||||
|
import Data.Maybe
|
||||||
|
import qualified GI.Gtk as Gtk
|
||||||
|
import Data.GI.Base
|
||||||
|
import GI.Gdk as Gdk
|
||||||
|
|
||||||
|
activate :: Gtk.Application -> IO ()
|
||||||
|
activate app = do
|
||||||
|
|
||||||
|
|
||||||
|
window <- new Gtk.ApplicationWindow [#application := app,
|
||||||
|
#title := "Wazajisho"]
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
controller <- Gtk.new Gtk.EventControllerKey []
|
||||||
|
|
||||||
|
Gtk.widgetAddController window controller
|
||||||
|
|
||||||
|
|
||||||
|
Gtk.on controller #keyPressed $ \_ keyval _ -> do
|
||||||
|
-- key <- Gdk.keyvalName keyval -- cant use this because the keyname doesnt always match the real key.
|
||||||
|
{--
|
||||||
|
i'll let the keycode displaying while i search for an actual solution for this, but it seems that
|
||||||
|
it can be a little hard to deal with keycodes: https://superuser.com/questions/1709357/difficulty-remapping-the-super-key
|
||||||
|
--}
|
||||||
|
print $ keyval
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
#show window
|
||||||
|
|
||||||
|
main :: IO ()
|
||||||
|
main = do
|
||||||
|
app <- new Gtk.Application [#applicationId := "wazajisho-test",
|
||||||
|
On #activate (activate ?self)]
|
||||||
|
|
||||||
|
args <- getArgs
|
||||||
|
progName <- getProgName
|
||||||
|
void $ #run app (Just $ progName : args)
|
||||||
Loading…
Reference in a new issue