Re: [clutter] change color of actor on button press event
- From: "Patrick Shirkey" <pshirkey boosthardware com>
- To: clutter-list gnome org
- Subject: Re: [clutter] change color of actor on button press event
- Date: Wed, 24 Oct 2012 12:04:34 +1100 (EST)
On Tue, October 23, 2012 8:34 pm, Patrick Shirkey wrote:
Hi,
What is the best method to change the color of an actor dynamically?
In the code I posted yesterday there is a set_color() function. It works
when the actor is created and initially displayed.
I tried adding a call to queue_redraw() in the set_color() function but
that only kicks in after button-release-event. I would like to change the
color of the actor on button-press-event.
def set_color(self, color):
"""Fill the shape with the color given in parameter.
color may be a Clutter.Color object or a string representing
the color name.
"""
if isinstance(color, Clutter.Color):
self._color = color
else:
self._color = Clutter.Color()
self._color.from_string(color)
I managed to bypass the color issue temporarily by using set_opacity()
instead. Now I see a different issue.
===
(keyboard.py:4260): Clutter-WARNING **: The required ID of 445892
does not refer to an existing actor; this usually implies that the
pick() of an actor is not correctly implemented or that there is an
error in the glReadPixels() implementation of the GL driver.
===
1: I can see the "button-press-event" is firing correctly and
change_color() is initiated but the release event is working
intermittently.
2: On some buttons it works almost every time but with other buttons not
at all.
3: The "button-leave-event" works for all buttons every time.
4: On the buttons that are *not* receiving "button-release-event" I get
the error above *after* the "button-press-event" is received and actioned.
- I have tested with clutter 0.8.4 (f16) and 1.10.2 (f17)
++++++++++++++++++++
def change_color(status, keytype, key_widget):
if(status == 0): # button-press-event
opacity = 200
else: # button-release-event/button-leave-event
opacity = 255
print("change color", status)
key_widget.set_opacity(opacity)
def on_click(self, *args):
key_widget = args[1]
keytype = args[2]
print('press event ',keytype)
change_color(0,keytype, key_widget)
def on_release(self, *args):
key_widget = args[1]
keytype = args[2]
print('release event ',keytype)
change_color(1,keytype, key_widget)
def on_leave(self, *args):
key_widget = args[1]
keytype = args[2]
print('leave event ', keytype)
change_color(1,keytype, key_widget)
def create_button():
roundrect = RoundRectangle()
stage.add_actor(roundrect)
roundrect.connect("button-press-event", on_click,roundrect, "w")
roundrect.connect('button-release-event', on_release,roundrect, "w")
roundrect.connect('leave-event', on_leave,roundrect, "w")
+++++++++++++++
--
Patrick Shirkey
Boost Hardware Ltd
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]