VoltageImage SetCurrentImage behaviour

Post Reply
terrymcg
Posts: 85
Joined: Mon Apr 08, 2019 12:35 am

VoltageImage SetCurrentImage behaviour

Post by terrymcg »

Hi Folks...

I have a control that I'd like to have change a displayed image (for another). Looking at the methods currently available in VoltageImage, I spotted SetCurrentImage, and thought that would make a neater solution than creating a stack of hidden images and toggling their visibility.

I've added the images as extra resources, but unfortunately, SetCurrentImage doesn't seem to trigger a re-draw of the image object, so the displayed image isn't updated until something else (tool tip overlap, mouse click etc.) triggers the refresh.

Toggling the image visibility (from visible to invisible and back to visible) does update the display, but seems awkward.

Is there a better way of forcing an image redraw in this sort of situation and/or am I expecting the wrong things from SetCurrentImage?

Cheers,
--
Terry McG
User avatar
seal58
Posts: 354
Joined: Fri Jul 12, 2019 5:28 pm
Location: Rostock, Germany
Contact:

Re: VoltageImage SetCurrentImage behaviour

Post by seal58 »

Hi,

if you don't have to change images from new sources, there's another way may be possible: define several images, with SetVisible() you can turn single images on and off.
User avatar
honki-bobo
Posts: 306
Joined: Sat Nov 09, 2019 1:18 pm

Re: VoltageImage SetCurrentImage behaviour

Post by honki-bobo »

You can draw an image into the Graphics2D object of a VoltageCanvas. That way you don't need any SetVisible() magic and simply draw the image you want to have visible.
Image
Monkey Business Audio
Modules - Music - Twitter - YouTube
terrymcg
Posts: 85
Joined: Mon Apr 08, 2019 12:35 am

Re: VoltageImage SetCurrentImage behaviour

Post by terrymcg »

Thanks for the suggestions!

I'm familiar with the hide-n-seek method, but was hoping to avoid it.

Drawing the image to a Canvas is a new idea (to me anyway), but for the moment I'll live with toggling the image object's visibility (to force a refresh).
These are UI-rate events, so it shouldn't add too much load.

Cheers,
--
Terry McG
Post Reply

Return to “Module Designer”