mirror of
https://gitlab.com/sheaf/metabrush.git
synced 2024-11-23 23:44:07 +00:00
fix accelerator key handling
This commit is contained in:
parent
e4779d8af2
commit
777b894c06
|
@ -674,15 +674,18 @@ instance HandleAction MouseClick where
|
||||||
DoubleClick -> do
|
DoubleClick -> do
|
||||||
tool <- STM.readTVar toolTVar
|
tool <- STM.readTVar toolTVar
|
||||||
mode <- STM.readTVar modeTVar
|
mode <- STM.readTVar modeTVar
|
||||||
|
modifs <- STM.readTVar modifiersTVar
|
||||||
case tool of
|
case tool of
|
||||||
Selection -> do
|
Selection
|
||||||
STM.writeTVar mouseHoldTVar Nothing
|
| null modifs
|
||||||
let
|
-> do
|
||||||
mbSubdivide :: Maybe Document
|
STM.writeTVar mouseHoldTVar Nothing
|
||||||
mbSubdivide = subdivide mode pos doc
|
let
|
||||||
case mbSubdivide of
|
mbSubdivide :: Maybe Document
|
||||||
Nothing -> pure Don'tModifyDoc
|
mbSubdivide = subdivide mode pos doc
|
||||||
Just newDoc -> pure ( UpdateDocTo $ Just newDoc )
|
case mbSubdivide of
|
||||||
|
Nothing -> pure Don'tModifyDoc
|
||||||
|
Just newDoc -> pure ( UpdateDocTo $ Just newDoc )
|
||||||
|
|
||||||
-- Ignore double click event otherwise.
|
-- Ignore double click event otherwise.
|
||||||
_ -> pure Don'tModifyDoc
|
_ -> pure Don'tModifyDoc
|
||||||
|
@ -951,11 +954,8 @@ instance HandleAction KeyboardPress where
|
||||||
vars@( Variables {..} )
|
vars@( Variables {..} )
|
||||||
( KeyboardPress keyCode ) = do
|
( KeyboardPress keyCode ) = do
|
||||||
|
|
||||||
modifiers <- STM.atomically do
|
for_ ( modifierKey keyCode ) \ modifier ->
|
||||||
!modifiers <- STM.readTVar modifiersTVar
|
STM.atomically $ STM.modifyTVar' modifiersTVar ( Set.insert modifier )
|
||||||
for_ ( modifierKey keyCode ) \ modifier ->
|
|
||||||
( STM.writeTVar modifiersTVar ( Set.insert modifier modifiers ) )
|
|
||||||
pure modifiers
|
|
||||||
|
|
||||||
case keyCode of
|
case keyCode of
|
||||||
|
|
||||||
|
@ -981,14 +981,6 @@ instance HandleAction KeyboardPress where
|
||||||
GTK.widgetQueueDraw viewportDrawingArea
|
GTK.widgetQueueDraw viewportDrawingArea
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
|
|
||||||
-- todo: these should be handled by accelerator,
|
|
||||||
-- but those are not working currently
|
|
||||||
GDK.KEY_Delete -> handleAction uiElts vars Delete
|
|
||||||
|
|
||||||
GDK.KEY_s
|
|
||||||
| any ( \case { Control _ -> True; _ -> False } ) modifiers
|
|
||||||
-> handleAction uiElts vars Save
|
|
||||||
|
|
||||||
_ -> pure ()
|
_ -> pure ()
|
||||||
|
|
||||||
----------------------
|
----------------------
|
||||||
|
|
|
@ -40,25 +40,25 @@ handleEvents :: UIElements -> Variables -> IO ()
|
||||||
handleEvents elts@( UIElements { viewport = Viewport {..}, .. } ) vars = do
|
handleEvents elts@( UIElements { viewport = Viewport {..}, .. } ) vars = do
|
||||||
|
|
||||||
-- Mouse events
|
-- Mouse events
|
||||||
onWidgetMouseEvent viewportDrawingArea ViewportOrigin
|
afterWidgetMouseEvent viewportDrawingArea ViewportOrigin
|
||||||
onWidgetMouseEvent rulerCornerDrawingArea ( RulerOrigin RulerCorner )
|
afterWidgetMouseEvent rulerCornerDrawingArea ( RulerOrigin RulerCorner )
|
||||||
onWidgetMouseEvent leftRulerDrawingArea ( RulerOrigin LeftRuler )
|
afterWidgetMouseEvent leftRulerDrawingArea ( RulerOrigin LeftRuler )
|
||||||
onWidgetMouseEvent topRulerDrawingArea ( RulerOrigin TopRuler )
|
afterWidgetMouseEvent topRulerDrawingArea ( RulerOrigin TopRuler )
|
||||||
|
|
||||||
-- Keyboard events
|
-- Keyboard events
|
||||||
void $ GTK.onWidgetKeyPressEvent window ( handleKeyboardPressEvent elts vars )
|
void $ GTK.afterWidgetKeyPressEvent window ( handleKeyboardPressEvent elts vars )
|
||||||
void $ GTK.onWidgetKeyReleaseEvent window ( handleKeyboardReleaseEvent elts vars )
|
void $ GTK.afterWidgetKeyReleaseEvent window ( handleKeyboardReleaseEvent elts vars )
|
||||||
|
|
||||||
-- Window quit
|
-- Window quit
|
||||||
void $ GTK.onWidgetDestroy window ( quitEverything window )
|
void $ GTK.onWidgetDestroy window ( quitEverything window )
|
||||||
|
|
||||||
where
|
where
|
||||||
onWidgetMouseEvent :: GTK.DrawingArea -> ActionOrigin -> IO ()
|
afterWidgetMouseEvent :: GTK.DrawingArea -> ActionOrigin -> IO ()
|
||||||
onWidgetMouseEvent drawingArea eventOrigin = do
|
afterWidgetMouseEvent drawingArea eventOrigin = do
|
||||||
void $ GTK.onWidgetMotionNotifyEvent drawingArea ( handleMotionEvent elts vars eventOrigin )
|
void $ GTK.afterWidgetMotionNotifyEvent drawingArea ( handleMotionEvent elts vars eventOrigin )
|
||||||
void $ GTK.onWidgetScrollEvent drawingArea ( handleScrollEvent elts vars eventOrigin )
|
void $ GTK.afterWidgetScrollEvent drawingArea ( handleScrollEvent elts vars eventOrigin )
|
||||||
void $ GTK.onWidgetButtonPressEvent drawingArea ( handleMouseButtonEvent elts vars eventOrigin )
|
void $ GTK.afterWidgetButtonPressEvent drawingArea ( handleMouseButtonEvent elts vars eventOrigin )
|
||||||
void $ GTK.onWidgetButtonReleaseEvent drawingArea ( handleMouseButtonRelease elts vars eventOrigin )
|
void $ GTK.afterWidgetButtonReleaseEvent drawingArea ( handleMouseButtonRelease elts vars eventOrigin )
|
||||||
|
|
||||||
--------------------------------------------------------------------------------
|
--------------------------------------------------------------------------------
|
||||||
-- Mouse events.
|
-- Mouse events.
|
||||||
|
|
Loading…
Reference in a new issue