Sto cercando un esempio di trascinamento e rilascio di haskell wx. Non ho ancora trovato nessuno.wx haskell Esempio di trascinamento e rilascio
Qualsiasi disponibile? o suggerimenti?
Finora:
- posso vedere un evento
on drag
(ma non "su goccia") - del mouse è solo dare un
left up
sul bersaglio vedo qualche commento in cui dovrei attache una destinazione di rilascio per su un oggetto, ma non vedere come viene richiamato:
Graphics.UI.WXCore.DragAndDrop
L 51
- | Crea "DropSource". Quindi 'dragAndDrop' sostituisce 'DataObject' di destinazione con questo 'DataObject'.
dropSource :: DataObject a -> Finestra b -> IO (DropSource())
non riesco a vedere la strato WX sopra Graphics.UI.WXCore.DragAndDrop
- questo è (troppo) io immagino: [0]: http://bb10.com/haskell-wxhaskell-general/2007-08/msg00035.html
in ogni caso, del tutto confusa per ora ...
edit: questo è dove mi trovo ora: su trascinamento non attivati, quindi non dragAndDrop o (sul mouse in xinput è lì per vedere che cosa sta succedendo) (dragger
è quello che ho ricevuto da [O]), ma lo faccio non ottenere l'evento da questo)
--- test where DnD from yinput to xinput
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
-- @next : try andrun start within a state
ballsFrame
= do
f <- frame [text := "Layout test"]
p <- panel f [] -- panel for color and tab management.
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] --, on keyboard := showMeK
set yinput [ ] --on mouse := showMe, on keyboard := showMeK ]
-- fileDropTarget xinput (\pt file -> putStrLn $ show file)
-- prepare the drop source
textdata <- textDataObjectCreate ""
drop <- dropTarget xinput textdata
textdata' <- textDataObjectCreate "text"
src <- dropSource textdata' yinput
-- activate on drag the do drag drop
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