Skip to main content
heyo
Associate III
November 21, 2022
Question

Custom container radio buttons

  • November 21, 2022
  • 4 replies
  • 1119 views

I create custom container and include one radio button in that container and then I want to create list of radio buttons. The problem is that when I touch one radio button other buttons does not deselected. How to include radio buttons in the same group? (in custom container)

This topic has been closed for replies.

4 replies

Yoann KLEIN
ST Employee
November 22, 2022

Hello @heyo​ ,

Could you please attach screenshots of the issue you have ? That could help us a lot to better visualize the problem.

Thanks,

/Yoann

Yoann KLEINST Software Developer | TouchGFX
heyo
heyoAuthor
Associate III
November 24, 2022

Ok. First of all I create one radio button in custom container:

0693W00000WJQLpQAP.pngThen I write this code in my custom container:

#include <gui/containers/example.hpp>
 
example::example()
{
 
}
 
void example::setupListElement(TEXTS iconTextID, int _index)
{
	index = _index;
	languagetxt.setTypedText(TypedText(iconTextID));
	languagetxt.resizeToCurrentText();
 invalidate();
}
int example::getIndex()
{
	return index;
}
 

Then I put that container in my screen window: Screen1

0693W00000WJQVGQA5.pngMy Screen1 code looks like that:

#include <gui/screen1_screen/Screen1View.hpp>
#include <texts/TextKeysAndLanguages.hpp>
Screen1View::Screen1View()
{
 
}
 
void Screen1View::setupScreen()
{
	list.setHeight(0);
	listElements[0].setupListElement(T_ENGLSIHID, 0);
 listElements[1].setupListElement(T_POLSKIID,1);
 listElements[2].setupListElement(T_DANSKID, 2);
 listElements[3].setupListElement(T_SVENSKAID, 3);
 
	for (uint8_t i = 0; i < numberOfListElements; ++i)
	{
		list.add(listElements[i]);
	}
}
 
void Screen1View::tearDownScreen()
{
 Screen1ViewBase::tearDownScreen();
}
void Screen1View::examplebuttoncalled()
{
	if(examples.getState())
	{
		scrollableContainer1.setVisible(true);
		scrollableContainer1.invalidate();
	}
	else
	{
		scrollableContainer1.setVisible(false);
		scrollableContainer1.invalidate();
	}
}

Start simulator and click on toggle button we see dropdown

0693W00000WJQVaQAP.pngIf I click for example english and polski it selects both of them(as usually if all buttons are in one group then if I click one option deselects another and so on).0693W00000WJQYFQA5.png So the question is this how to add all radio buttons in one group programmatically? In this project I use a lot of dropdowns and I need to create them dinammically because it allocate a lot of microprocessor memory.

ABIZO.1
Associate II
November 24, 2022

Do you check if all your radio button are on the same group ?

heyo
heyoAuthor
Associate III
November 25, 2022

Hi, Yoann KLEIN

I've tried do like this, but still does not work. Do you have any suggestions?

0693W00000WJUGyQAP.png

Yoann KLEIN
ST Employee
November 28, 2022

Hello @heyo​ ,

What does your callback method look like ?

I mean the method which is called when you click on your radio buttons?

/Yoann

Yoann KLEINST Software Developer | TouchGFX