Repaint... how to know when it's done?


#1

I need to have some graphical response for my component, as in getting the midi noteOn message to switch the drawed image to be different for a sec to let user know there’s been a hit.

The problem is that as painting is quite “unreliable” in when it happens, my image returns to original before the drawing happens on screen, and the switch never shows visually…

I wonder is there a way to check if repaint has been done for a component?

…Or any other methods to get reliable graphical response like this?


#2

Maybe there is an even better way, but why don’t you simply set a flag in paint()?


#3

Ah thanks for the tip, somehow I think I understood the logic in paint() wrong, but this made it clear for me. :slight_smile:


#4

IMHO you shouldn’t rely on that information, as a repaint can be triggered by a lot of circumstances, not only from your code, but from the OS as well, e.g. when the window is resized, when another window is dragged over it etc…

There’s a very good chance that the user didn’t see your paint result when the next paint already started.

A better approach would be to add a timeout to make sure, all paints in a certain time period show that feedback.


#5

Ah yeah, okay, thanks! :slight_smile: