Finally I figured out how to bring DND to life. I do not know what are
the TargetLists for but it works the same with them and also without
them. Here is a code snipset:
-- new game button
buttonNewGame <- buttonNewWithLabel "New Game"
onClicked buttonNewGame (newGame buttonNewGame)
boxPackStart vboxButtons buttonNewGame PackGrow 0
-- quit button
buttonQuit <- buttonNewWithLabel "Quit"
onClicked buttonQuit mainQuit
boxPackStart vboxButtons buttonQuit PackGrow 0
dragSourceSet buttonNewGame [Button1] [ActionCopy]
dragDestSet buttonQuit [DestDefaultAll] [ActionCopy]
buttonQuit `on` dragDataReceived $ \ ctx p ii ts -> do liftIO (putStrLn "data-received")
d <- selectionDataGetText
liftIO (putStrLn ("data are: " ++ (show d)))
buttonNewGame `on` dragDataGet $ \ ctx ii ts -> do
liftIO (putStrLn "data-get")
On Mon, Aug 24, 2009 at 4:19 PM, Bulat Ziganshin <firstname.lastname@example.org> wrote:
Monday, August 24, 2009, 6:53:03 PM, you wrote:
(i rerouted asnwer to gtk2hs list)
> Hi, have somebody used drag and drop feature of Gtk2hs? I can't find
> any tutorial or demo. I'm using only the documentation but I think I'm> missing something. Can anyone give me an example?
Yeah, I used DND in my file manager, I think there might be a code example on my blog http://www.mickinator.com/wordpress but I'm not 100% sure.
I'll have a look later and get back to you with an example. I found the one included with gtk2hs quite confusing :)
there is filemanager program mentioned in gtk2hs news that supports
btw, i also have question regarding d&d - does it work only inside
gtk2hs/gtk programs or it's possible to d&d between Windows Explorer
and my program? i'm writing filemanager too ;)
I'd say there is maybe a way to get transferance between gtk apps, but I think at this stage using gtk2hs it would be a nightmare, I remember writing the DND and finding it very hacky. Then again I may have done it wrong!
You would have to know what was being dropped/dragged, and have a means of accepting it and handling it.
It would be interesting though :)