Skip to main content
MPast.1
Senior
February 12, 2021
Question

Flex Button swap trigger from toggle to click from user code

  • February 12, 2021
  • 1 reply
  • 938 views

Hi All,

is it possibile to change a FlexButton Trigegr from code?

I would like to change from toggle to click and viceversa.

Has someone some hints?

thank's in advance

This topic has been closed for replies.

1 reply

Alexandre RENOUX
Visitor II
February 22, 2021

Hello MPast.1,

One idea would be to create your own button widget. Note that this means you will not be able to see it in the Designer.

In the end you would declare your flexButton in your View header file like something as follows

touchgfx::ImageButtonStyle< touchgfx::CustomButtonTrigger > myFlexButton;

You create this CustomButtonTrigger class that will behave like ToggleButtonTrigger or ClickButtonTrigger according to some input. (Your class will inherit AbstractButtonContainer like in the ToggleButtonTrigger and ClickButtonTrigger class).

Or you can completely recreate a Button based on the Button classes to have all the features you want in a single class. Your choice ;)

/Alexandre

MPast.1
MPast.1Author
Senior
February 25, 2021

Hi Alexander,

thank you for the suggestion : , as soon as possibile I will try this mode.

Sometimes is necessary to change by code the trigger mode of a button (or other object).

I will be useful if the new release contain this mode. Can you evaluate to insert this mode in the next revision?

thanks

Romain DIELEMAN
ST Employee
February 26, 2021

Hi,

Could you add this idea in the Idea Zone of this forum ? This will help us keep track of this. This will unlikely be added to the next release, but we never know for the next one ;).

I can add that another work around would be to have two buttons (same position, looks, ...) and you switch to the one with the trigger you need when needed.

/Romain