@@ -27,7 +27,7 @@ module Reflex.Vty.Widget
27 , Region(..)
27 , Region(..)
28 , regionSize
28 , regionSize
29 , regionBlankImage
29 , regionBlankImage
30− , Drag (..)
30+ , Drag(..)
32 , mouseDown
32 , mouseDown
@@ -278,7 +278,11 @@ drag
278drag btn = do
278drag btn = do
279 inp <- input
279 inp <- input
280 let f :: Maybe Drag -> V.Event -> Maybe Drag
280 let f :: Maybe Drag -> V.Event -> Maybe Drag
281− f Nothing = const Nothing
281+ f Nothing = \case
282+ V.EvMouseDown x y btn' mods
283+ | btn == btn' -> Just $ Drag (x,y) (x,y) btn' mods False
284+ | otherwise -> Nothing
282 f (Just (Drag from _ _ mods end)) = \case
286 f (Just (Drag from _ _ mods end)) = \case
283 V.EvMouseDown x y btn' mods'
287 V.EvMouseDown x y btn' mods'
284 | end -> Just $ Drag (x,y) (x,y) btn' mods' False
288 | end -> Just $ Drag (x,y) (x,y) btn' mods' False
@@ -301,13 +305,30 @@ drag btn = do
302 :: (Reflex t, Monad m)
306 :: (Reflex t, Monad m)
303 => V.Button
307 => V.Button
304− -> VtyWidget t m (Event t VtyEvent)
308+ -> VtyWidget t m (Event t MouseDown)
305mouseDown btn = do
309mouseDown btn = do
306 i <- input
310 i <- input
307− return $ fforMaybe i $ \x -> case x of
311+ return $ fforMaybe i $ \case
308− V.EvMouseDown _ _ btn' _ -> if btn == btn' then Just x else Nothing
312+ V.EvMouseDown x y btn' mods -> if btn == btn'
313+ then Just $ MouseDown btn' (x, y) mods
309 _ -> Nothing
315 _ -> Nothing
317+-- | Information about a mouse down event
318+data MouseDown = MouseDown
319+ { _mouseDown_button :: V.Button
320+ , _mouseDown_coordinates :: (Int, Int)
321+ , _mouseDown_modifiers :: [V.Modifier]
323+ deriving (Eq, Ord, Show)
325+-- | Information about a mouse up event
326+data MouseUp = MouseUp
327+ { _mouseUp_button :: Maybe V.Button
328+ , _mouseUp_coordinates :: (Int, Int)
330+ deriving (Eq, Ord, Show)
311-- | A plain split of the available space into vertically stacked panes.
332-- | A plain split of the available space into vertically stacked panes.
312-- No visual separator is built in here.
333-- No visual separator is built in here.
313splitV :: (Reflex t, Monad m)
334splitV :: (Reflex t, Monad m)