From: frantisek k. <fra...@gm...> - 2009-08-25 20:09:32
|
dBtw. is there any way that destination accepts/rejects data according to data to be send? DragMotion function seems to do exactly that. I implemented it with always returning False and nothing changed. Destination still accepts drops... Here is my code: i `on` dragMotion $ \ctx p ts -> do putStrLn "dragMotion" return False The function dragFinish seems also handy. It is working with DragContextClass how I can get one? Thanks Fero On Tue, Aug 25, 2009 at 9:52 PM, frantisek kocun <fra...@gm...>wrote: > Thank you! > > 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 > > > -- DND > dragSourceSet buttonNewGame [Button1] [ActionCopy] > dragDestSet buttonQuit [DestDefaultAll] [ActionCopy] > > dragSourceAddTextTargets buttonNewGame > dragDestAddTextTargets buttonQuit > > buttonQuit `on` dragDataReceived $ \ ctx p ii ts -> do liftIO (putStrLn > "data-received") > > d <- selectionDataGetText > > liftIO (putStrLn ("data are: " ++ (show d))) > > return () > > buttonNewGame `on` dragDataGet $ \ ctx ii ts -> do > liftIO (putStrLn "data-get") > selectionDataSetText "hahaha" > return () > > On Mon, Aug 24, 2009 at 5:45 PM, Michael Dever <mic...@ma... > > wrote: > >> >> On Mon, Aug 24, 2009 at 4:19 PM, Bulat Ziganshin < >> bul...@gm...> wrote: >> >>> Hello frantisek, >>> >>> 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 >>> d&d >>> >>> 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 :) >> >> Regards, >> Michael >> >> >> >> > |