How can I detect if the user has double-clicked in pygame?

后端 未结 5 1477
夕颜
夕颜 2020-12-06 07:34

I know I can check if there was a left click

event.type == pygame.MOUSEBUTTONDOWN and event.button == LEFT

but how can I check if they doub

5条回答
  •  温柔的废话
    2020-12-06 07:49

    I've never used pygame - but:

    • Detecting double clicks: at a guess, instead of processing each click immediately, apply a 50ms delay and see if you get another click event in that time. The user probably won't notice the 50ms delay.

    • Distinguishing between scrollwheel up/down: see the comments on this documentation page. Apparently there are five buttons defined - left, middle, right, scrollwheel-up and scrollwheel-down. That is, you can capture scrollwheel events the same way you're capturing left clicks - you just need to look for SCROLL_UP or similar instead of LEFT.

      Look up the documentation to find out exactly what SCROLL_UP is called.

提交回复
热议问题