Implementing Image Buttons

Widget

Well-Known Member
Licensed User
Longtime User
When using bitmaps on a button, there is no automatic image change when the button is pressed. I can of course use the Up/Down events to display a different image when the button is DOWN. This means of course creating a second image for the button. Also if the image is disabled, I would have to create a 3rd image for the bitmap and grey it out.

Is there a better way to conserve memory instead of creating 3 bitmaps for the same button? I know I can draw a colored rectangle around the bitmap button when it is Down, and remove it when it is UP so it changes "color" when it is pressed. This gives the user visual feedback that the button was pressed.

Has anyone perfected this? I'm thinking of drawing a semi-transparent orange rectangle with rounded corners around the button when the Down event is triggered, and redraw the original bitmap image when the Up event is triggered. I could use this for all of the buttons and just resize the rectangle to fit the button dimensions.

Does this seem practical? Has this already been done?

TIA
Widget
 

thedesolatesoul

Expert
Licensed User
Longtime User
I used a canvas to draw on a button. But I havent done anything for button_down yet.
Mainly because my buttons are quite small and I dont think the user will be able to see anything under his fat fingers!
However, it is just a question of Memory vs CPU trade-off.
You may store the bitmaps, that will be faster but will consume more memory (however even a 128x128 bmp is only 64KB),
Or you can write a sub to take a button as an argument and re-draw the button. I do not see an issue with this approach unless you are doing other intensive operations at the same time. (I would go for this one if it is fairly easy to draw the bitmap using code).
 
Upvote 0

nfordbscndrd

Well-Known Member
Licensed User
Longtime User
... This gives the user visual feedback that the button was pressed...

An alternative is to provide audible feedback:

Dim Feedback As Beeper
Feedback.Initialize(30, 30)
Feeback.Beep

The above settings (30,30) are not very loud and give a nice "click" sound, but you can adjust them to your taste. The user can always turn the volume on his device up or down to his taste.

Something else I have done is to put an orange label behind a button so that it looks like a border around it and make it visible when the button is down and not visible when the button comes up.
 
Upvote 0
Top