开发者

How do I detect events on a group in PyClutter?

I am trying to detect mouse clicks (and other events) on groups in PyClutter. But they don't seem to trigger anything. Here is what I have:

import clutter
col = clutter.Color(1, 0, 0)
r1 = clutter.Rectangle(col)
r2 = clutter.Rectangle(col)
r1.set_size(100, 50)
r2.set_size(50, 100)
r2.set_position(200, 200)
g = clutter.Group()
g.add(r1)
g.add(r2)
stage = clutter.Stage()
stage.add(g)
def onClickGroup(group, click):
    print "Group", click

g.connect("button-press-event", onClickGroup)
def onClickRect(rect, click):
    print "Rect", click

r1.connect("button-press-event", onClickRect)

def onClickStage(stage, click)开发者_JS百科:
    print "Stage", click

stage.connect("button-press-event", onClickStage)
stage.show_all()

When I try to run it, my only output is

>>> Stage <Button Press at 74, 31; button: 1; time: 49748777; source actor: ClutterStage at 0x0x8a21008>

So it isn't picking up the events from the individual actors. Is there any way to make individual actors or groups detect events?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜