From: shelarcy <she...@gm...> - 2007-08-03 03:54:00
Attachments:
DragAndDrop.hs
ImageViewer.hs
|
Hi all, Does anyone try to add drag & drop support? I heard that Gtk2Hs 0.9.12 added this feature. http://www.haskell.org/pipermail/libraries/2007-July/007711.html http://www.haskell.org/pipermail/libraries/2007-July/007810.html So I tried adding this feature to wxHaskell, current a few weeks. Attached are drag & drop event module, and test sample that is made by modifying ImageViewer sample. (This file isn't good example, because drag & drop event only made dialogbox instead of doing reasonable act.) And if there is already someones work, please let me know it. Because if it's good enough, I want to stop duplicate work and make patch sooner by using it. Best Regards, -- shelarcy <shelarcy hotmail.co.jp> http://page.freett.com/shelarcy/ |
From: Eric Y. K. <eri...@gm...> - 2007-08-05 19:42:40
|
On Fri, Aug 03, 2007 at 12:53:43 +0900, shelarcy wrote: > And if there is already someones work, please let me know it. > Because if it's good enough, I want to stop duplicate work > and make patch sooner by using it. I think you should go ahead and submit this as a patch. Note that I haven't had a chance to play around with it yet. Best, --=20 Eric Kow http://www.loria.fr/~kow PGP Key ID: 08AC04F9 Merci de corriger mon fran=E7ais. |
From: shelarcy <she...@gm...> - 2007-08-16 05:37:36
|
Hi Eric, On Mon, 06 Aug 2007 04:42:35 +0900, Eric Y. Kow <eri...@gm...> wrote: > On Fri, Aug 03, 2007 at 12:53:43 +0900, shelarcy wrote: >> And if there is already someones work, please let me know it. >> Because if it's good enough, I want to stop duplicate work >> and make patch sooner by using it. > > I think you should go ahead and submit this as a patch. Okay, I sent patch for that. http://article.gmane.org/gmane.comp.lang.haskell.wxhaskell.general/246 Its patch also includes clipboard support, because wxWidgets uses same Type as drag & drop for this purpose. > Note that I > haven't had a chance to play around with it yet. There are no difficult to use drag & drop. If you want to drop files for a Control, this is very easy task. fileDropTarget set target control and event handler. fileDropTarget :: Window a -> (Point -> [String] -> IO ()) -> IO () Point is dropped posiotion of that, and [String] is dropped files' pathes. So you can set file drop target and event like this. fileDropTarget sw (\pt file -> do infoDialog sw (show pt) (show file)) If you dragging-on files to non-target control, you can see cursor that means you can't drop files to target control. If you dragging-on files to target control, you can see cursor that has reversal meaning. If you want to drop something that can map DataObject (text data, bitmap data, and so on), first you must set drop source and drop target, then do dragAndDrop in dragging event as below. set sw [on drag := \pt -> dragger sw f] dragger win wout = do textdata <- textDataObjectCreate "" drop <- dropTarget wout textdata textdata' <- textDataObjectCreate "text" src <- dropSource textdata' win dragAndDrop src Default (\_ -> return ()) txt <- textDataObjectGetText textdata infoDialog wout "resultText" txt textdata has null String in creation time. But this String is changed by drop sources' textdata' after drop event is endded. So, print txt shows "text" (I don't know the correct way to use textDropTarget, so I use dropTarget in this sample. If you want to use textDropTarget, you can just replace dropTarget ... but I thins this is not correct way). And clipboard function changes DataObject same as drop source doing. execClipBoardData cl (\clp -> do textdata'' <- textDataObjectCreate " " clipboardGetData clp textdata'' txt <- textDataObjectGetText textdata'' infoDialog wout "clipboard data" txt) Using Drag & Drop and ClipBoard aren't difficult. But I don't have enogh experience with those features yet. So please use, and send me feedbacks for that. Best Regards, -- shelarcy <shelarcy hotmail.co.jp> http://page.freett.com/shelarcy/ |
From: shelarcy <she...@gm...> - 2007-08-16 10:56:09
|
I'm sorry for I am confused Window with Control. On Thu, 16 Aug 2007 14:37:22 +0900, shelarcy <she...@gm...> wrote: > If you want to drop files for a Control, this is very easy task. > fileDropTarget set target control and event handler. > > fileDropTarget :: Window a -> (Point -> [String] -> IO ()) -> IO () > Point is dropped posiotion of that, and [String] is dropped files' > pathes. It and other dropTarget functions specify Window, not Control. Best Regards, -- shelarcy <shelarcy hotmail.co.jp> http://page.freett.com/shelarcy/ |