I am looking for an example of wx haskell Drag and Drop. I haven't found one yet.
Are there any available? or hints?
Still:
- I see the event
on drag(but not "drop by drop") - the mouse just gives
left upfor the purpose I see some comment where I have to set the target’s passport to the object, but I don’t see how it is called:
Graphics.UI.WXCore.DragAndDrop
L 51
- | Create a DropSource. Then "dragAndDrop" replaces the target DataObject with this "DataObject".
dropSource :: DataObject a -> Window b -> IO (DropSource ())
I don’t see where the WX layer is located above Graphics.UI.WXCore.DragAndDrop
- This is (also) old, I think: [0]: http://bb10.com/haskell-wxhaskell-general/2007-08/msg00035.html
, ...
edit: :
, dragAndDrop
( xinput , )
(dragger , [O]), )
module Main where
import CustoWidget
import Graphics.UI.WX hiding (empty)
import Data.Graph.Inductive
import Data.Maybe
import Control.Monad
import Graphics.UI.WX.Events
import Graphics.UI.WXCore.WxcClassesMZ
import Graphics.UI.WXCore.WxcClassesAL
import Graphics.UI.WXCore.DragAndDrop
import Graphics.UI.WXCore.Events
import Debug.Trace
main
= start ballsFrame
ballsFrame
= do
f <- frame [text := "Layout test"]
p <- panel f []
ok <- button p [text := "Ok"]
can <- button p [text := "Cancel", on command := infoDialog f "Info" "Pressed 'Cancel'"]
xinput <- textEntry p [text := "100", alignment := AlignRight]
yinput <- textEntry p [text := "100", alignment := AlignRight]
set f [defaultButton := ok
,layout := container p $
margin 10 $
column 5 [boxed "coordinates" (grid 5 5 [[label "x:", hfill $ widget xinput]
,[label "y:", hfill $ widget yinput]])
,floatBottomRight $ row 5 [widget ok,widget can]]
]
set xinput [ on mouse := showMe]
set yinput [ ]
textdata <- textDataObjectCreate ""
drop <- dropTarget xinput textdata
textdata' <- textDataObjectCreate "text"
src <- dropSource textdata' yinput
set yinput [ on drag := onDrag src]
set ok [ on command := onOk f textdata]
return ()
onDrag s p = trace ("on drag " ++ show s ++ " " ++ show p)
dragAndDrop s Default (\_ -> return ())
onOk f textdata = do
txt <- textDataObjectGetText textdata
infoDialog f "resultText" txt
close f
showMe = \x -> do putStrLn $ show x
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