google / gxui

An experimental Go cross platform UI library.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

type MouseEvent: buttons are not handled

DoctorovEV opened this issue · comments

Ben, good Health!

How to determine which mouse button is pressed in event OnMouseMove?

Hi @DoctorovEV,
Currently you cannot.
If you want this, then:

  • The MouseButton enum should become a MouseButtonState bitfield, and should have the following methods added:
func (s MouseButtonState) IsLeftDown() bool { ... }
func (s MouseButtonState) IsMiddleDown() bool { ... }
func (s MouseButtonState) IsRightDown() bool { ... }
  • MouseEvent.Button should be renamed to ButtonState.
  • All the places where a MouseEvent is created in viewport.go should be updated to assign the ButtonState field.
  • All the existing code that checks for button equality would have to be updated to use the IsLeftDown() / IsMiddleDown() / IsRightDown() methods instead.

I can do this, but I'm exceptionally busy this week. I'm happy to review a pull-request if you're comfortable doing this yourself.

Cheers,
Ben

Thank you, Ben. I'll wait for the official implementation of the next week.

@yofu has done the hard work on this. Please reopen if this doesn't give you what you need.