cancel
Showing results for 
Search instead for 
Did you mean: 

Setting RadioButton state without triggering action.

franck23
Senior

Hi,

I have 3 radio-buttons in a custom container which is present on several screens.

I would like the radio-buttons to keep their states between when switching screens.

I have the radio-buttons states reported to the model every time a button is pressed and when the screen changes, the new active view fetches the radio-button state.

However, I do not see a function to update a radio-button state without triggering the button action.

Is there such a function?

12 REPLIES 12
MM..1
Chief II

Why you define callbacks in base code, when i create screen with radio my code is

/*********************************************************************************/
/********** THIS FILE IS GENERATED BY TOUCHGFX DESIGNER, DO NOT MODIFY ***********/
/*********************************************************************************/
#include <gui_generated/screen1_screen/Screen1ViewBase.hpp>
#include <touchgfx/Color.hpp>
#include "BitmapDatabase.hpp"
 
Screen1ViewBase::Screen1ViewBase()
{
 
    __background.setPosition(0, 0, 800, 480);
    __background.setColor(touchgfx::Color::getColorFrom24BitRGB(0, 0, 0));
 
    toggleButton1.setXY(336, 193);
    toggleButton1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_TOGGLEBARS_TOGGLE_ROUND_LARGE_BUTTON_OFF_ID), touchgfx::Bitmap(BITMAP_BLUE_TOGGLEBARS_TOGGLE_ROUND_LARGE_BUTTON_ON_ID));
 
    radioButton1.setXY(356, 43);
    radioButton1.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_INACTIVE_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_PRESSED_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_ACTIVE_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_NORMAL_ID));
    radioButton1.setSelected(false);
    radioButton1.setDeselectionEnabled(false);
 
    radioButton2.setXY(356, 104);
    radioButton2.setBitmaps(touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_INACTIVE_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_PRESSED_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_ACTIVE_ID), touchgfx::Bitmap(BITMAP_BLUE_CHECK_BUTTONS_CHECK_MARK_NORMAL_ID));
    radioButton2.setSelected(true);
    radioButton2.setDeselectionEnabled(false);
 
    add(__background);
    add(toggleButton1);
    add(radioButton1);
    add(radioButton2);
    radioButtonGroup1.add(radioButton1);
    radioButtonGroup1.add(radioButton2);
}
 
void Screen1ViewBase::setupScreen()
{
 
}

no callbacks here...

place this in view setup code after change selected states

radioButtonGroup.setRadioButtonSelectedHandler(radioButtonSelectedCallback);

franck23
Senior

The callback defined in the base file has been generated using TouchGFX designer.

The code I have added is in the MainView.cpp.

As i write when you plan change state against designer states, without call callback, then you can dont generate callbacks to base file, and do it yourself in setup code ...

maybe too is possible redefine callback to null , set new group state and reaply original callback, but this i dont try.