EaselJS: Changing Shape Color on De-select - shapes

(Note: Just to clarify, by "de-select" I mean selecting other shape than the currently selected one, thereby de-selecting the initially selected shape)
Just to elaborate a bit more, I got a series of shapes on a canvas. Any shape I click on changes its color from, say, red to white. But then, there can only be ONE white-colored shape at any given time. That means, if I click on shape-A first then shape-B, shape-A's color must change from white back to red the moment I click on shape-B.
Adding a "click" event listener to every shape was a no-brainer. But, I am at a loss as to how to point back to the previous shape object so that I can restore its original color.
Any help will be much appreciated!
Update: Upon further research, I'm starting to think that my objective boils down to this - Finding a way to point to any Shape object NOT through some event listener but via a method call by passing the object's ID. However, I just checked the Shape class methods here but didn't see anything that might be useful. Could I be missing something here?

(I hope I understood you correctly)
Your "issue" is more of a program-flow issue that is not really specific to a easeljs or any ObjectType.
All you have to do is set a (global) reference to the clicked object inside the click-listener, i'd call it window.lastClickedShape or something similar. And whenever a shape is clicked you check if lastClickedShape != null and reset the color for that object.

Related

How to change an image in MS PowerPoint, when mouse over and out

I need help to change an image when mousing over in PPT.
There are 3 answers on the slide. https://prnt.sc/tzulzc
When mousing over the image to choose the correct answer, I would like to the image change to another image, or just color change so that a user would know he/she can choose it. And then when mousing out again, it gets back to the previous image.
In that case of shape, not image, I could get help in the link below.
https://www.brightcarbon.com/blog/supercharging-powerpoint-interactive-presentations-with-vba-part-2/
But I couldn't get the accurate result since I applied it to the grouped shape.
I did try finding out something online and get nothing.
I hope someone gives me an idea.
Thank you.
MouseOver events only fire once as the pointer moves from NotOverShape to OverShape (I'm making these terms up ... they're not constants or properties, other than conceptually).
The event won't fire when the mouse leaves the shape.
What you can do is add another (100% transparent) shape just behind the real shape you're working with and slightly larger. Now when the mouse moves into the real shape, it'll pass over the "bogus" shape and trigger a mouseover. Likewise, when the mouse moves OUT of the real shape, the same thing will happen.
A mouse-over macro attached to the bogus shape could toggle the value of a global boolean, say InBound. If InBound is true, do {whatever you need to} or if it's false, {undo whatever you've done}.

Is there any event that fire for PowerPoint animations at start and end?

We're developing a PowerPoint plugin, recently we got a requirement from our client to start certain functionality after animation on an object is completed but I'm not able to find any animation finished or started events.
As PeterT has mentioned, there are no events fired when shapes animate. But here's a possible workaround. It may or may not fit your needs:
Add a shape the size of the animated shape, give it a Run Macro Action Setting on mouse-over (not on click). Have it run whatever macro you've written to do what's needed.
Make the shape 99% transparent and animate it to appear automatically after the main shape you've animated.
Result: your original shape animates on, then the (for all intents) invisible add'l shape appears and as soon as the user wiggles the mouse, the macro fires.
If you can't be sure that the user will have the mouse over the shapes in question, try adding a full-slide shape instead to trigger the macro. In that case, to avoid having the macro trigger repeatedly, you might need to have the macro make the shape that triggers it invisible or have the macro remove the action setting or the like.

What secret things are happening to my NSButtonCell?

I'm writing an OS X app (target 10.10, Xcode 6.1) and I'm really confused by my custom NSButtonCell subclass. It seems like there are things going on here that shouldn't. I'm new to OS X programming, so I'm asking if anyone has insight into the inner workings of NSButtonCell.
First, what seems to be working?
I can set the button's image and title. The image appears normally.
The storyboard sets up the button to be Style: Textured and Type: Momentary Change. It's not Bordered, not Transparent, and doesn't allow Mixed State.
List of complaints:
I override -drawTitle:withFrame:inView: to draw the title in a custom color depending on the cell's highlighted. This color should be #cccccc when the cell is not highlighted, but it's actually #d6d6d6.
The button has both image and alternate image. The image that's drawn is never the alternate image, so I override -drawImage:withFrame:inView: to pick the correct image for cell's highlighted. This appears to work, but what the heck, NSButtonCell? How is on/off state different from highlighted? I've tried many of the Type options and none seem to change the fact that pressing the button will momentarily change highlighted, and toggle state.
Speaking of momentarily changing highlighted, it appears that its duration is about as short as possible, so I had to implement a sort of "debouncer" to prevent -drawWithFrame:inView: from being called more frequently than a specified threshold.
My button cell also has properties myBackgroundColor and myAlternateBackgroundColor. I'm not using backgroundColor because I need to be able to draw a custom background shape (filled rect, filled circle, etc). The alternate background color is used when highlighted. The problem here is that the alternate background color should be #93edbf but appears to be #a1eecb! In order to get it to look like #93edbf, I need to set the color to #84ecb2.
So far this has all been about one particular instance of this button cell. But in another instance, the alternate background isn't drawing at all! I've read through the storyboard code and the buttons are as identical as they can be. My view controller code likewise updates both button cells' properties at the same time. Why would one button behave differently from another?
I want the button to highlight on mouse down instead of "momentarily" after mouse up. I haven't yet implemented this in my custom cell. Man, NSButtonCell is really lacking some things. How does something like that happen? Don't the OS X and iOS teams ever talk to each other?
What could it be?
I've already verified that the cell's controlTint is set to NSClearControlTint. I've checked for background filters, compositing filters and content filters on the off chance they had anything to do with this.
I know Apple really wants us to use their native look and feel for UI elements, but I never thought they'd go so far as to force the use of some highlight tint.

How to make an object invisible at a particular keyframe without moving it in Blender (2.59)?

I'm quite new to blender, and I'm doing some experiments with it.
I've been searching for a way to make an object disappear from sight at a particular key-frame, without moving it out of the camera view. E.g. at frame 1, cube is there, at (0, 0, 0) and at frame 2, it's not visible anymore, but still there at position (0,0,0), at frame 3 it gets visible again.
After searching the web, I came upon this page which suggests to move the object to another layer, but since it applies to blender 2.49, it seems the software has changed since then: I'm unable to find the 'Layer' option when inserting a key-frame.
I've found some other sites but either they suggest to use a technique similar to the one linked above, or they suggest to change the alpha of the texture, which I'm not interested in.
So, what's the preferred method to make an object invisible in blender 2.59?
Additional information (not relevant for the answer I'm expecting, IMO):
I'm using blender to make models for Unity.
I'm using 2.59 because that's the one that works with the unity version that I have.
There are lots of ways to achieve this effect.
The easiest way is to keyframe the visibility of the object.
To do this, you simply go to the outliner, and click the little eyeball next to your object name, then hover over the closed eyeball and hit "i" to keyframe. The eye will then turn yellow to indicate it's keyframed. Do the same with the camera icon (so that your render behaves the same way). Then go to the point where you want the object to appear, and click the eyball and camera again to make them reappear, then hit "i" again over each to keyframe them... Isn't blender a wonderful program? I love being able to keyframe just about everything! :D
There are also these less easy, but variously useful methods, which you may also use in case you want some sort of transition in your vanishing/appearing:
My perferred way is to just move the opbejct off the screen, keyframe position, then set the animation (in the Graph Editor) curve type to "constant" (Key -> Interpolation Mode -> Constant), and move the object into place and set the keyframe where you want it to appear. It will thus instantaneously appear.
Set the material properties of the object to Transparent, and choose "Z-Transparency" and set alpha to 0. Then simply keyframe the alpha (hover mouse over Alpha value and hit "i"), then go to where you want it to appear, change the alpha value to 1, and keyframe again. This will make it fade in over time, or you can change the curve to constant in the Graph editor, as described in method 1.
If you want to mask the object while it is still in place, you could make a cube around it, set the cube material transparency to "mask", and then move the cube off camera to unmask the object, rather than moving the object. This is handy for when you want to partially unmask something in the course of the animation. For example, if you are creating a text overlay for a video, where you want text to appear as if it's coming out of your hand, you can animate the masked object to follow the contour of your hand as it pulls away to reveal the text.
In Blender 2.65, you can animate the objects visibility toggle in your Outliner panel.
Next to your scene objects there will be three icons: an eye, a cursor, and a camera.
Follow these steps to animate viewport visibility:
Find the object you wish to animate in the Outliner Panel
Mouse over the eye icon and hit "i" on your keyboard to set a keyframe.
Go to the next frame and turn the eye off, then hit "i" moused over it again.
Do the same thing with the camera icon to animate render visibility. I will usually keyframe both the viewport and render visibility icons in tandem so as not to forget to have these toggled when its time to render.
In version 2.9 the eye icon cannot be used to set a keyframe. I've found the best way for me is to use the Object Properties tab and under Transform set the three scale values (X,Y,Z) to zero for invisibility. You can then click the diamond to the right to set the keyframe. To make the object re-appear return the scale values to their original and click on the diamond keyframe icon again.
Obviously you can make it a lot easier for yourself by applying scale to the objects first then just switch them between 0 and 1.
AFAIK there is no easy way to directly set an object invisible in your case. Although the visibility can be animated in Blender (in outline view mive your cursor on the eye and press i) Unity3D doesn't recognise it.
Possible workarounds:
Move it to (1000, 0, 0)
Scale it by a very small value
A more elaborated approach could be to use a driver like when turning FK/IK animation on and off dynamically via a variable.
I found out (today!) that, in Blender 2.8 (& presumably beyond), you can control visibility of objects in animations either in viewports and/or renders. Select the object and, in the Object Properties, open the Visibility section. You will see a dot beside the Viewports and Renders options. Click on the dot in either Viewports or Renders (or both). The relevant boxes should turn green. Either make the object visible or invisible by checking or clearing its box and then click 'i' to insert a keyframe. Repeat the process in other keyframes.
Another way to do this is to make a cube around it and add a boolean modifier to the object you want to disappear, set the operation to difference and select the cube as the modifier's object target. Then turn off the cube's visibility and animate the visibility of the modifier.

Draw Lines on gtk.TextView

I'm trying to show the "selection" of a certain sub-string in a
gtk.TextView by drawing a border around the word. The only way to mark
text in a TextView that I've found so far is by placing TextTags with
modified properties. This does not seem to offer a way to draw a border,
though, DOES GTK SUPPORT THIS OR IS THIS A PROBLEM WITH ONLT PYGTK
I figured out how to draw on a text view !!!
To begin with lets assume the reference to your gtk.TextView is in a variable called viewer, Inside one of ur classes
Also the draw function has to be called with an event called expose-event else the drawings will be refreshed and will not stay on the screen
The next part is the gtk.TextView consists of 7 types of gtk.gdk.windows on which u can draw
gtk.TEXT_WINDOW_WIDGET
gtk.TEXT_WINDOW_TEXT
gtk.TEXT_WINDOW_LEFT - not displayed by default
gtk.TEXT_WINDOW_RIGHT - not displayed by default
gtk.TEXT_WINDOW_TOP - not displayed by default
gtk.TEXT_WINDOW_BOTTOM
gtk.TEXT_WINDOW_PRIVATE
For the drawing to appear on gtk.TextView We have to draw on gtk.TEXT_WINDOW_TEXT
An Example Code is as shown Below
if(viewer!=None):
viewer.connect("expose-event", expose_view)
self.drawable=viewer.get_window(gtk.TEXT_WINDOW_TEXT)
def expose_view(self,window,event):
if(self.drawable!=None):
self.drawable.draw_line(self.drawable.new_gc(),1,1,30,30)
# (1,1) and (30,30) are the coordinates and u can give the values accordingly
In a gtk.TextBuffer tags are used to set one or more pre-defined text attributes. Without subclassing, this is limited to the properties of a gtk.TextTag, and doesn't include anything akin to a border or outline property. There is no difference between PyGTK and plain GTK+ in this regard.
While somewhat hacky, the easiest way to do what you want to do is to connect to the expose-event of your gtk.TextView, get the coordinates of your string and draw on event.window, which is the gdk.Window of the event provided in the expose callback.
(Note that you don't have to get and store the gtk.TEXT_WINDOW_TEXT window, you just need to check what window the expose event is for in the callback, probably ignoring the expose if it's not for the text window.)
Instead, you could presumably subclass one or more of TextBuffer/TextView/TextTag to add a border tag, but whether it's reasonable to do so is another question.