Mason
Mason

Reputation: 15

Pyglet on_mouse_click not detected

I'm new to Pyglet, but I've messed with Pygame and JFrames before. I'm having trouble with the on_mouse_click() event for Pyglet. It doesn't seem to ever be called, though all the other events (including on_mouse_release and on_mouse_drag). I have all the events logged, so it shows me every event that occurs.

Here's a simplified version of what I'm doing:

import pyglet

window = pyglet.window.Window(width=640, height=480)
window.push_handlers(pyglet.window.event.WindowEventLogger())

label = pyglet.text.Label("Hello world", font_name="Times New Roman" ,
                          font_size=36, x=window.width // 2, y=window.height // 2, 
                          anchor_x="center, anchor_y="center")
@window.event
def on_mouse_press(x,y,button,mod):
    print("Button Pressed")

pyglet.app.run()

My version is python 3.6. I'm using the PyCharm IDE (I've also tested it through cmd), Pyglet 1.3.1, and I'm using Windows 10

Upvotes: 0

Views: 465

Answers (2)

Yuriy Leonov
Yuriy Leonov

Reputation: 504

1.3.2 doesn't have this issue. So at this moment you can upgrade pyglet version.

Upvotes: 1

Attila Toth
Attila Toth

Reputation: 469

I had the same problem with pyglet version 1.3.1, everything worked except the on_mouse_press() method, so i downgraded to version 1.3.0 and now everything works fine. You can specify the version you want to install with pip like so:

pip install pyglet==1.3.0

Upvotes: 3

Related Questions