Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug: onBtnPressed ignores middle mouse button clicks #63

Closed
Litoprobka opened this issue Jan 14, 2022 · 3 comments
Closed

Bug: onBtnPressed ignores middle mouse button clicks #63

Litoprobka opened this issue Jan 14, 2022 · 3 comments
Labels
bug Something isn't working correctly

Comments

@Litoprobka
Copy link

A box with onBtnPressed / onBtnReleased completely ignores clicks on the middle mouse button.

Here's a small isolated example.

example
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TemplateHaskell #-}

module Main where

import Control.Lens
import Data.Maybe
import Data.Text (Text, pack)
import Monomer
import TextShow

import qualified Monomer.Lens as L

newtype AppModel = AppModel {
  _lastClick :: Text
} deriving (Eq, Show)

data AppEvent
  = AppInit
  | LastClick Text
  deriving (Eq, Show)

makeLenses 'AppModel

buildUI
  :: WidgetEnv AppModel AppEvent
  -> AppModel
  -> WidgetNode AppModel AppEvent
buildUI wenv model = widgetTree where
  widgetTree =
      box_ [expandContent, onBtnPressed handleClick]
        (label (model ^. lastClick) `styleBasic` [textCenter])

handleClick b times = LastClick $ pack (show b) <> " pressed " <> showt times <> " times"

handleEvent
  :: WidgetEnv AppModel AppEvent
  -> WidgetNode AppModel AppEvent
  -> AppModel
  -> AppEvent
  -> [AppEventResponse AppModel AppEvent]
handleEvent wenv node model evt = case evt of
  AppInit -> []
  LastClick t -> [Model (model & lastClick .~ t)]

main :: IO ()
main = do
  startApp model handleEvent buildUI config
  where
    config = [
      appWindowTitle "Hello world",
      appTheme darkTheme,
      appFontDef "Regular" "./assets/fonts/Roboto-Regular.ttf",
      appInitEvent AppInit
      ]
    model = AppModel "No button presses yet"

Tested on:

  • Void Linux PC (mouse)
  • Void Linux laptop (touchpad)
  • Windows 10 laptop (mouse)

with Monomer 1.2.0.0

@fjvallarino
Copy link
Owner

Hi @Litoprobka!

I had missed converting middle button actions from SDL2 events to Monomer events. I pushed a new branch (the PR is linked to this issue). To use it, you will need to update your stack.yaml:

- git: https://github.com/fjvallarino/monomer.git
  commit: d34cd780c8cc0244b40da09e69dcbff316e75555

Thanks for reporting this!

@Litoprobka
Copy link
Author

Thank you for replying so fast!

@fjvallarino fjvallarino added the bug Something isn't working correctly label Jan 14, 2022
@fjvallarino
Copy link
Owner

Since I merged to main and deleted the branch, the commit hash mentioned previously does not exist anymore. Below is the new one from main (which will never be removed). This change will be included in 1.3, which ideally will be released in 1-2 weeks.

- git: https://github.com/fjvallarino/monomer.git
  commit: 4e0f8fadab633718ecdcfa7322e66e9ec58a7ee6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working correctly
Projects
None yet
Development

No branches or pull requests

2 participants