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

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}.

Related

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.

Want To Create A Floating Speech Bubble Form

Wondering if someone could help me....
I have a small .NET application where I have an Edit button on a main form. When the user clicks the Edit button, I want to popup a small form right next to it (on top of the main form) with a speech balloon tail attached on the side of the form pointing to the Edit button. So it gives the effect of a floating form pushed out from the Edit button.
I don't want the appearance of a normal speech bubble, I want it to look like an actual borderless form (with square corners). It could be a custom control or anything (however, I am not yet familiar with creating my own custom controls), but I need to add Text Controls, Pictures, Label Controls, etc. to this floating form.
Any help would be appreciated.
Thanks
UPDATE
I am trying to create something to this affect:
So imagine the ? being the Edit button and the other being a form with custom controls.
Like this?
To get this behavior:
Select an image which will represent your speech bubble. Put a PictureBox on the form, make it use this image. Place two labels, as above, adjust the font.
Pick your transparency key (color). Your image background and form background need to be set to that. I used black for demo purposes, which is a bad choice if you plan to have any black or text in your speech bubble. Set form's TransparencyKey property to this color in designer. More about TransparencyKey on MSDN.
(final step, not shown on the screenshot). Set FormBorderStyle = None.
Also make sure you have other ways to close your bubble, because X will be unavailable.
The final result may look something like the following:
Note: You may notice some drawing artifacts, most images on the internet have smooth borders, and transparency key does not support shades, has to be exact color. If you are fine with these minor artifacts, feel free to leave it at that. Or, edit it to get rough borders. Or find another one that better suits your needs.

EaselJS: Changing Shape Color on De-select

(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.

Rectangles & Parsing in vb.net

This is kinda....a two part question. The first one is much more important than the second one, both of these are in the same project, and in vb.net.
How can I constrain the bounds of a rectangle object, which is controlled by a mouse, so it cannot be drawn outside a PictureBox? It is kindof a standard lasso control, the user can click and drag and it will draw a box from the initial click point to the mouse's current location. The starting point is at (rectX,rectY), and the box is drawn to the bottom right using rectDimX and rectDimY (to set the width and height) to see how much of a change has occurred with the mouse. Basically, its what you get with a click and drag on a Windows desktop. The issue here is that the rectangle is able to be drawn outside the PictureBox it is being drawn on, and the next part of the code attempts to reference this location, and then fails with an OutOfMemory exception. This leads me to my second question:
How can I make the rectangle draw in more than the fourth quadrant, which is only positive numbers? If it goes anywhere else, it does not show the rectangle, though it does still have the correct values. I know i could code this four times based on starting location and mouse location, but that would be a huge hassle and a rewrite of the whole rectangle code.
Is there an easy solution for either of these? The first one is a much bigger hassle, as it will be very time consuming if there is no easy way.
Thanks for the help!
For the first part of your question, even if the user drags the mouse beyond the edge of your picture box, you don't have to use those coordinates for your drawing routine. Simply do something like
If (DrawingPoint.X > PictureBox.Right)
DrawingPoint.X = PictureBox.Right // Right-hand limit of picture box
End If
And similar for the Y direction.
As for the negative numbers while drawing, you want to translate screen coordinates to client area coordinates. Have a look at ScreenToClient and ClientToScreen.

Picture box goes blank

In VisualBasic.Net When I activate a picture box and then draw something on it, it draws and then immediately goes blank. Works fine when I re-draw it, but almost always messes up the first time I draw on it. This has happenned with several different programs, and the help file is no help.
Try setting the DoubleBuffered property
http://msdn.microsoft.com/en-us/library/system.windows.forms.control.doublebuffered.aspx
If that's not it, please provide more info.
Usually, if you're drawing something on a picture box or on another control, you have to take over the OnPaint event, and you're responsible of persisting what you draw on this event.
Thank you Andrew, but no help. I'm using .Net Framework 1.1, which does not offer the DoubleBuffered property... it was new in 2.0.
Not sure what additional info to provide.. the code is 300 lines long. When a button is clicked, the code expands my form, makes two picture boxes visible (one on top of the other (the back one is for some graph labels), and then uses some graphic brushes and pens to draw a graph on the front box. There's some database activity and calculations going on in the background at the same time.
I assume you're using the standard PictureBox component. Do you draw in the Paint-Handler? If not then the PictureBox will just erase your painted stuff next time it's asked to redraw itself (erase background etc.).
Yes, I believe I am using the standard picture box.
By Paint-Handler, I assume you mean a [Control].PaintEvent Handler. No I'm not using an event handler to do the drawing... drawing my chart is not an event in itself, but part of a much larger response to a button click event.
If you are saying that having the drawing code be part of a separate and specific handler can solve my problem, than I guess I could raise an internal event every time I want to redraw the chart. But I Would rather just figure out what is causing the PB to redraw itself without being told to.
If you cannot use the DoubleBuffered than you can HIDE a second picture box. You do the drawing in it and once it's completed you draw back to the VISIBLE one. This way the process of drawing is done on the hidden one and the white/flickering will not be shown.