Button overimage and selection


ImageButton supports a total of 3 state images: Normal, Over and Down.
In my application it is important for me to allow users to navigate using the keyboard.

Is there a simple way to make the button use the Over state image upon gaining keyboard focus?
I want the user to be aware that the button is focused and the most natural way is using the Over state image (I think it should be default behavior).


I’m not sure if this is an ‘appropriate method’, but I use this method to get more than the standard ‘normal/hover/down’ images. I have derive from ImageButton, override ‘paintButton’, and call a routine in there which sets up the image for the button based on the criteria I want (in your case it will have to do with focus/no focus). In my case, this button has an image for up, up with mouse pressed, down, and down with mouse pressed.

void MyButton::paintButton (Graphics& g, bool isMouseOverButton, bool isButtonDown)
    SetUpImages(isMouseOverButton, isButtonDown);
    ImageButton::paintButton(g, isMouseOverButton, isButtonDown);

I also used this method in a button that I wanted animated. In that case I have a timer callback which calls a similar ‘SetUpImages()’, which selects the appropriates frames from the animation strip for the button.


I'm looking to create an animated Image button from a vertical strip of frames, do you have any example code describing the techniques you used?