Skip to content

Instantly share code, notes, and snippets.

@wavewave
Last active December 12, 2015 10:09
Show Gist options
  • Select an option

  • Save wavewave/4756944 to your computer and use it in GitHub Desktop.

Select an option

Save wavewave/4756944 to your computer and use it in GitHub Desktop.
gtk2hs simplest drag and drop test
--
-- 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
@wavewave
Copy link
Copy Markdown
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment