我正在寻找一个 wx haskell 拖放示例。我还没有找到。
有可用的吗?或提示?
至今:
- 我可以看到一个
on drag
事件(但没有“on drop”) - 鼠标只是给出一个
left up
目标 我看到一些评论,我应该在 object 上附加一个放置目标,但我看不到它是如何被调用的:
Graphics.UI.WXCore.DragAndDrop
大号 51
-- | 创建'DropSource'。然后“dragAndDrop”用这个“DataObject”替换目标的“DataObject”。
dropSource::DataObject a -> Window b -> IO (DropSource())
我看不到 Graphics.UI.WXCore.DragAndDrop 上方的 WX 层在哪里
- 我猜这(太)旧了:[0]:http ://bb10.com/haskell-wxhaskell-general/2007-08/msg00035.html
反正现在很模糊……
编辑:这就是我现在的立场:在拖动时不会被激活,所以也没有 dragAndDrop(在 xinput 中的鼠标上只是为了看看发生了什么)(dragger
是我从 [O] 得到的),但我没有从中获取事件)
--- 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