Mouse Events (Trigger vs Polling)

Window has a KeyUp and KeyDown event. But I can’t find where mouse motion and button events would be. Is there such a thing? I don’t want to rely on game frames and polling to deal with it if I can help it.

There aren’t any built in events for mouse that I’m aware of. You can create your own, though, if you want. I believe the key events were specifically designed for text input, which is why they exist but mouse events do not.

What do you have against polling? The nature of a game’s update loop is well suited to it. You can store the previous update/frame’s mouse state, and the current one, and raise an event for button click if the mouse button was up on the previous frame and down on the current one.

1 Like

I shouldn’t say I’m against it, I just didn’t want to implement some solution that might already exist, but alas, seems I’ll have to.

MonoGame.Extended is an unofficial extension of MonoGame that you could use. It appears to have built in InputListener capabilities with events, as seen here. You could use that if you want. I’ve never used it myself, that I can remember.