Skip to main content
Zui
Senior
July 1, 2019
Question

is it possible, when a button is pressed, to make another button show the pressed image?

  • July 1, 2019
  • 5 replies
  • 1364 views

In my current project i have a menu. The graphic guy decide every menu part have an icon, a text and a small arrow, all are gray end when are pressed they became blue. any way to make them all show pressed state when i click one? Or should i make a big image(mostly empty) with all 3 image on it?

Thanks

This topic has been closed for replies.

5 replies

Martin KJELDSEN
Principal III
July 1, 2019

Hi @Zui​,

It sounds to me like your graphics guy did not know that it would make your life MUCH easier to just make one single image =) Yes, you can do what you ask, simply call bitmap.setBitmap() on your images witth the new bitmap id (The color you want) and then bitmap.invalidate();

/Martin

Zui
ZuiAuthor
Senior
July 1, 2019

that's not clear to me, where i call the setBitmap() function? because the image should change when button is pressed, but function is called when button is released. let's say mu butto call foo(), when it is pressed it switch the image to his pressed image (and here i should call my function to change other images, but i have no idea how to intercept this event, i can't reimplement handleClickEvent because i can intercept every ClickEvent::PRESSED, but can't distingue the source of the click event) and he call his assign fuction when is released, here i can add what i want, but i need to switch image when it's pressed and holded, not released...

Martin KJELDSEN
Principal III
July 1, 2019

(But, i would just ask him to redo the image - It makes the code less complex also)

Zui
ZuiAuthor
Senior
July 1, 2019

another problem is i should also change the color of a text, so i can't use an image, because text will change with language selected, so i really need a way to call a function when a button is pressed o make the color change when that button is holded

Zui
ZuiAuthor
Senior
July 1, 2019

EDIT: i solved, thanks for hints!

Martin KJELDSEN
Principal III
July 2, 2019

Great, @Zui​,

I'm assuming you figured out that you can change the color of a text programatically.

/Martin

Zui
ZuiAuthor
Senior
July 2, 2019

well, i'm not that unskilled, problem was change only when button was clicked and holded and chage it back when button was released(both released with his function called, and released my mocing finger away like when u change your mind or have pressed the wrong button, but i made that work by messing around with handleClickEvent and handleDragEvent