Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2012-03

Grouping radio buttons

16 messages · 8 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Jürgen Hestermann

I already searched for hours but cannot find anything useful.

My question:
Is it possible (and if yes, how) to group some radio buttons so that only one of each group can be selected?

I put some radio buttons on my form which select different things but they are all connected with each other so that only one can be selected at a time.

I expected some property defining a goup but I cannot find anything like that.

Reply by email

Mattias Gaertner
to Jürgen Hestermann
Show quoted text 12 lines
I already searched for hours but cannot find anything useful. My question: Is it possible (and if yes, how) to group some radio buttons so that only one of each group can be selected? I put some radio buttons on my form which select different things but they are all connected with each other so that only one can be selected at a time. I expected some property defining a goup but I cannot find anything like that.

Use a TRadioGroup or put the radiobuttons on a panel. Hint: A Panel can become invisible with BevelOuter=bvNone.

Mattias

Reply by email

Jürgen Hestermann
to Mattias Gaertner
Show quoted text 6 lines
> Is it possible (and if yes, how) to group some radio buttons > so that only one of each group can be selected? Use a TRadioGroup or put the radiobuttons on a panel. Hint: A Panel can become invisible with BevelOuter=bvNone.

I already read a bit about TRadioGroup. But it seems that this restricts the physical location of the buttons on the form or am I wrong? I would like to be able to place the radio buttons at arbitrary places on the form.

A panel seems to be doable but it's still awkward. Now the locations of the radio buttons are located relative to the panel and I have to rearrange them all. I thought that there is some logical grouping that is independend from the visible location but it seems this does not exist.

Reply by email

Mattias Gaertner
to Jürgen Hestermann
Show quoted text 16 lines
Mattias Gaertner schrieb: > >> Is it possible (and if yes, how) to group some radio buttons >> so that only one of each group can be selected? > > Use a TRadioGroup or put the radiobuttons on a panel. > Hint: A Panel can become invisible with BevelOuter=bvNone. I already read a bit about TRadioGroup. But it seems that this restricts the physical location of the buttons on the form or am I wrong? I would like to be able to place the radio buttons at arbitrary places on the form. A panel seems to be doable but it's still awkward. Now the locations of the radio buttons are located relative to the panel and I have to rearrange them all. I thought that there is some logical grouping that is independend from the visible location but it seems this does not exist.

Well, placing them randomly would confuse users.

In a panel you can place the radiobuttons anywhere you want.

Mattias

Reply by email

Luiz Americo Pereira Camara
to Jürgen Hestermann: I already searched for hours but cannot find anything useful. My question: Is it possible…
J?rgen Hestermann wrote 12 lines
I already searched for hours but cannot find anything useful. My question: Is it possible (and if yes, how) to group some radio buttons so that only one of each group can be selected? I put some radio buttons on my form which select different things but they are all connected with each other so that only one can be selected at a time. I expected some property defining a goup but I cannot find anything like that.

Some time ago, i needed the same feature so implemented a TRadioButton.GroupIndex property where only the radio buttons with the same GroupIndex would be affected.

In win32 worked fine but could not implement nor in gtk2 or qt due to how native radio buttons are designed in those widgetsets

So, your best bet is to use panel.

Luiz

Reply by email

Hans-Peter Diettrich
to Jürgen Hestermann: I already read a bit about TRadioGroup. But it seems that this restricts the physical…
A panel seems to be doable but it's still awkward. Now the locations of the radio buttons are located relative to the panel and I have to rearrange them all. I thought that there is some logical grouping that is independend from the visible location but it seems this does not exist.

The grouping model (by parent) originates in Windows and was not extended in Delphi. Logical groups would require additional data structures in a form (member arrays...), and could cause conflicts with e.g. Frames.

I don't see how a user will recognize arbitrary radio button groups, with related buttons scattered across a form. Buttons in a panel or RadioGroupBox instead are naturally perceivable as related. Thus IMO the given model enforces a clearly structured GUI.

DoDi

Reply by email

Jürgen Hestermann
to Hans-Peter Diettrich
I don't see how a user will recognize arbitrary radio button groups, with related buttons scattered across a form. Buttons in a panel or RadioGroupBox instead are naturally perceivable as related. Thus IMO the given model enforces a clearly structured GUI.

When writing "arbitrary" I did not mean to randomly scatter them over the window. There can be multiple columns of radio buttons with text between them or other arrangements. The same question could be asked about TRadioButtons in general: Why can i put them *anywhere* although they are correlated? No visible connection is needed in this case. But it's only one group. No way to divide them into multiple groups. I would have expected a simple group number property that lets me set the group of some radio buttons to 1 and others to 2.

Reply by email

Martin Schreiber
to Jürgen Hestermann
J?rgen Hestermann wrote 15 lines
Hans-Peter Diettrich schrieb: > I don't see how a user will recognize arbitrary radio button groups, > with related buttons scattered across a form. Buttons in a panel or > RadioGroupBox instead are naturally perceivable as related. Thus IMO > the given model enforces a clearly structured GUI. When writing "arbitrary" I did not mean to randomly scatter them over the window. There can be multiple columns of radio buttons with text between them or other arrangements. The same question could be asked about TRadioButtons in general: Why can i put them *anywhere* although they are correlated? No visible connection is needed in this case. But it's only one group. No way to divide them into multiple groups. I would have expected a simple group number property that lets me set the group of some radio buttons to 1 and others to 2.

MSEgui TRadioButton equivalent (tbooleaneditradio) has an integer "group" property as well. A useful feature.

Martin

Reply by email

Graeme Geldenhuys
to Luiz Americo Pereira Camara: Some time ago, i needed the same feature so implemented a TRadioButton.GroupIndex…
Luiz Americo Pereira Camara <luizmed at ... wrote
Some time ago, i needed the same feature so implemented a TRadioButton.GroupIndex property where only the radio buttons with the same GroupIndex would be affected.

That is exactly how fpGUI does it too since the start. This seems much more logical than being forced to embed them in a (unwanted) panel.

As Felipe mentioned, maybe the Custom Draw widgets can come (yet again) to the rescue.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Graeme Geldenhuys
to Hans-Peter Diettrich: The grouping model (by parent) originates in Windows and was not extended in Delphi.…
Hans-Peter Diettrich wrote
Buttons in a panel or RadioGroupBox instead are naturally perceivable as related.

That is highly dependent on the UI layout. For a clean and uncluttered look, panels don't help the cause much. Having component free from bounding panels, also allow for much more flexibly layout when things are being resized by the end-user, dpi changes, themes changes, dynamic content added at runtime (eg: help text inserted and pushing component apart temporarily) etc... We don't live in boxes or grids (hopefully <smile>), so why should our UI components.

Regards, ? - Graeme - _______________________________________________ fpGUI - a cross-platform Free Pascal GUI toolkit http://fpgui.sourceforge.net

Reply by email

Hans-Peter Diettrich
to Graeme Geldenhuys
Show quoted text 7 lines
On 20 March 2012 03:34, Hans-Peter Diettrich <DrDiettrich1 at a....> wrote: > Buttons in a panel or RadioGroupBox instead are naturally perceivable as > related. That is highly dependent on the UI layout. For a clean and uncluttered look, panels don't help the cause much.

Most layout managers and widgetsets organize layouts in rectangles, docking managers do it the same way. This "regular" model is both a simple and stable approach, encouraging clean layouts at the same time. IMO it's the equivalent of structured code, for the GUI.

Show quoted text 5 lines
Having component free from bounding panels, also allow for much more flexibly layout when things are being resized by the end-user, dpi changes, themes changes, dynamic content added at runtime (eg: help text inserted and pushing component apart temporarily) etc...

All these issues can be handled nicely in a regular approach.

We don't live in boxes or grids (hopefully <smile>), so why should our UI components.

Undisciplined or uneducated users prefer to write spaghetti code, and to hack together some irregular GUI or webpages. They are on their own when nobody wants to have a look at their code or applications, due to the lack of an obvious structure.

DoDi

Reply by email

Jürgen Hestermann
to Martin Schreiber: MSEgui TRadioButton equivalent (tbooleaneditradio) has an integer "group" property as…
MSEgui TRadioButton equivalent (tbooleaneditradio) has an integer "group" property as well. A useful feature.

Nice to hear. I find this principle so apparent that I was a bit astonished that it was not implemented in TRadioButton as well. TRadioButton also allow an arbitrary placement of the buttons but why only 1 group?

Nevertheless, I now found a solution with TRadioGroup that solves my current problem with radio buttons.
Thanks for all the help.

In the end such problems are also often lack of knowledge. Too bad that I can't spent more time on experimenting with Lazarus. Mostly I have to just get it running while I would like much more to find the most elegant way. But that requires an excellent knowledge about all possible ways to implement something to pick the best.

Reply by email

Salvatore Coppola
to Jürgen Hestermann: I already searched for hours but cannot find anything useful. My question: Is it possible…

Put them in varius GroupBoxes so you can use the groupbox caption to logically(visual) differenziate each group of radiobuttons

Salvatore

2012/3/19 J?rgen Hestermann :

Show quoted text 19 lines
I already searched for hours but cannot find anything useful. My question: Is it possible (and if yes, how) to group some radio buttons so that only one of each group can be selected? I put some radio buttons on my form which select different things but they are all connected with each other so that only one can be selected at a time. I expected some property defining a goup but I cannot find anything like that. -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Jürgen Hestermann
to Salvatore Coppola
Put them in varius GroupBoxes so you can use the groupbox caption to logically(visual) differenziate each group of radiobuttons

As already discussed, this also means to abandon individual placing of the buttons.

I have now used one TRadioGroup and TRadioButton elements for the second group . But only the latter can be arranged free. If I need multiple groups of radio buttons only one can be put as I want. The other ones are pressed into the TRadioGroup arrangement (which is not bad, but sometimes you need more freedom).

Reply by email

Salvatore Coppola
to Jürgen Hestermann

Off topic (maybe)
I often use for the matter TComboBox with Style:=csDropDownList ==> only one choise per list (drastic reduction of space consumption) Salvatore

2012/3/21 J?rgen Hestermann :

Show quoted text 21 lines
Salvatore Coppola schrieb: > Put them in varius GroupBoxes so you can use the groupbox caption to > logically(visual) differenziate each group of radiobuttons As already discussed, this also means to abandon individual placing of the buttons. I have now used one TRadioGroup and TRadioButton elements for the second group . But only the latter can be arranged free. If I need multiple groups of radio buttons only one can be put as I want. The other ones are pressed into the TRadioGroup arrangement (which is not bad, but sometimes you need more freedom). -- _______________________________________________ Lazarus mailing list http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email