2020-02-20 09:48 AM
How can I disable the TRIGGER / Click button by switching the TRIGGER / Toggle button?
2020-02-20 01:20 PM
I believe it's setTouchable() for a regular button
For example to disable the touch on a toggle button
toggleButton1.setTouchable(false);
2020-02-21 02:24 AM
Hello thank you!
I have a "ButtonOffOn" toggle button. I have a "ButtonNext" button that changes the screen. I want the button "ButtonNext" to be locked while the "ButtonOffOn" button is switched on until the "ButtonOffOn" button is switched again.
I checked your suggestion but disables the "ButtonOffOn" button.
"ButtonOffOn" = On -> "ButtonNext" closed
"ButtonOffOn" = Off -> "ButtonNext" is active
How to do it?
2020-02-21 07:19 AM
I suppose you could do something like this: in Designer you create 2 interactions. The first one calls a new function when the button "ButtonNext" is clicked. The other interaction changes the screen when an hardware button is clicked. This is a fake button we use in order to generate the go to screen 2 transition function and use it in our code.
Then I added this in Screen1View.cpp
void Screen1View::functionNextOrStay()
{
if (ButtonOnOff.getState() == TRUE) // getState returns TRUE when On
{
application().gotoScreen2ScreenNoTransition();
}
}
Tell me if this enough for what you need, I did not need to use setTouchable() since it does not influence the result.
/Romain
2020-02-21 09:23 AM
Thank you for the offer. This is not what I mean but I will finally answer when I try.
I got that I deactivate another button with the button but I stopped to return to the active one
2020-02-21 09:35 AM
I made a quick tutorial for what you want now that i know exactly what you're trying to do. https://youtu.be/CSQkVLIN22k
There is a link to another video i made before for those who are interested. The toggle button on screen1 disables a button on screen2.
2020-02-21 10:11 AM
Hi Karl!
Yes, this is it. I still have to check how it will work when the OFF / ON button is Flex Button.
2020-02-21 10:54 AM
Well a flex button doesn't have a on/off state but you can still trigger off that button. So for that flex button, the C++ code will check the current touchable state of the buttonNext and toggle the touchable state to the opposite.
if(buttonNext.isTouchable() == true)
{
buttonNext.setTouchable(false);
buttonNext.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255,0,0));
buttonNext.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255,0,0));
buttonNext.invalidate();
}
else
{
buttonNext.setTouchable(true);
buttonNext.setLabelColor(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
buttonNext.setLabelColorPressed(touchgfx::Color::getColorFrom24BitRGB(255,255,255));
buttonNext.invalidate();
}
2020-02-22 04:46 AM
Thank you Karl!
Everything works as you wrote. Toggle Button has the function APPERANCE / Pressed. If I didn't choose it, it didn't work as I wanted. As I chose it worked correctly. For aesthetic reasons, I wanted to use the Flex Button. Although I set up TRIGGER / Togle did not work as I wanted. With the last sent code it works as I wanted. Thank you very much.
2020-02-22 04:52 AM
You're welcome! I'm glad I was able to help.