Last active
December 12, 2015 10:09
-
-
Save wavewave/4756944 to your computer and use it in GitHub Desktop.
gtk2hs simplest drag and drop test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| -- | |
| -- drag and drop test gist | |
| -- | |
| -- created by D.Wagner | |
| -- | |
| import Control.Monad.IO.Class | |
| import Graphics.UI.Gtk | |
| main = do | |
| initGUI | |
| w <- windowNew | |
| l <- labelNew $ Just "drag here lol" | |
| onDestroy w mainQuit | |
| containerAdd w l | |
| dragDestSet w [DestDefaultMotion, DestDefaultDrop] [ActionCopy] | |
| dragDestAddTextTargets w | |
| w `on` dragDataReceived $ \dc pos id ts -> do | |
| s <- selectionDataGetText | |
| liftIO . putStrLn $ case s of | |
| Nothing -> "didn't understand the drop" | |
| Just s -> "understood. here it is : <" ++ s ++ ">" | |
| widgetShowAll w | |
| mainGUI |
Author
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Copied from http://stackoverflow.com/questions/10966397/could-someone-explain-gtk2hs-drag-and-drop-to-me-the-listdnd-hs-demo-just-isnt