Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » Elevate Web Builder Technical Support » Support Forums » Elevate Web Builder General » View Thread |
Messages 1 to 10 of 10 total |
Radios deselected |
Wed, Jan 6 2016 12:14 PM | Permanent Link |
Matthew Jones | I have code to create radio buttons at run time. In the loop that is
creating them, code identifies the one that should be selected, and sets it as checked. In EWB1, this worked. In EWB2, creating another radio button clears the check from the earlier one. szItem := GetItem(); while szItem <> '' do begin xRadio := DuplicateRadio(radioDetailMaster, MainPanel); xRadio.Caption := szItem; if TestSomething() then xRadio.SelectionState := ssSelected; szItem := GetItem(); end; I can work around this by remembering the one to select until the end, but it strikes me as an imperfect situation to have the selection of another item cleared. -- Matthew Jones |
Wed, Jan 6 2016 12:21 PM | Permanent Link |
Raul Team Elevate | On 1/6/2016 12:14 PM, Matthew Jones wrote:
> I have code to create radio buttons at run time. In the loop that is > creating them, code identifies the one that should be selected, and > sets it as checked. In EWB1, this worked. In EWB2, creating another > radio button clears the check from the earlier one. Is your "DuplicateRadio" also copying the SelectionState ? Within a group only 1 radio can be selected so if you set any other to ssSelected when creating then any any other in the same group should get deselected. Raul |
Thu, Jan 7 2016 4:24 AM | Permanent Link |
Matthew Jones | Raul wrote:
> Is your "DuplicateRadio" also copying the SelectionState ? > > Within a group only 1 radio can be selected so if you set any other > to ssSelected when creating then any any other in the same group > should get deselected. Good thought, but no. Indeed, the master is not selected. -- Matthew Jones |
Thu, Jan 7 2016 8:58 AM | Permanent Link |
Raul Team Elevate | On 1/7/2016 4:24 AM, Matthew Jones wrote:
> Good thought, but no. Indeed, the master is not selected. I did a quick test here and while it works there is also something weird i'm seeing - i can only select first or last radio in the group. if i do this in code r1 := TRadioButton.Create(Form1); r1.left := 72; r1.top := 200; r2 := TRadioButton.Create(Form1); r2.left := 72; r2.top := 240; r3 := TRadioButton.Create(Form1); r3.left := 72; r3.top := 280; r3.selectionState := ssSelected; then everything works OK and r3 was selected however moving the selection state to radio 2 (middle one) results in none of the radios being selected //radio 1 r1 := TRadioButton.Create(Form1); r1.left := 72; r1.top := 200; //radio 2 r2 := TRadioButton.Create(Form1); r2.left := 72; r2.top := 240; r2.selectionState := ssSelected; //radio 3 r3 := TRadioButton.Create(Form1); r3.left := 72; r3.top := 280; Extending this to 4 radio controls i can only select 1 and 4 and not middle ones. And if i create the radio 4 before radio 3 (in code) then none are selected - almost looks like the logic that iterates thru the "other peer" radio controls (meaning same group/parent) does not properly set the selection states except for first and last found radio. Need Tim to look into this - I can't see anything obvious wrong with code but maybe i missed something additional. Raul |
Thu, Jan 7 2016 9:51 AM | Permanent Link |
Matthew Jones | Raul wrote:
> there is also something weird i'm seeing Yep, that's basically my code. If you move your r2.selectionstate to the end, it will also work. -- Matthew Jones |
Thu, Jan 7 2016 10:51 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Matthew,
<< Yep, that's basically my code. If you move your r2.selectionstate to the end, it will also work. >> I'll check it out. Tim Young Elevate Software www.elevatesoft.com |
Thu, Jan 7 2016 11:01 AM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Raul,
<< Need Tim to look into this - I can't see anything obvious wrong with code but maybe i missed something additional. >> Okay, I looked into it, and the issue is that you guys are forgetting that the default state is ssIndeterminate. When you create the last radio button, it is created with a selection state of ssIndeterminate, and a group of radio buttons can't have one ssIndeterminate and other non-ssIndeterminate selections, so it forces them *all* to ssIndeterminate. The solution is to not set any selection states until *after* you've created all of the radio buttons for the group: procedure TForm1.Button1Click(Sender: TObject); var r1: TRadioButton; r2: TRadioButton; r3: TRadioButton; begin //radio 1 r1 := TRadioButton.Create(Form1); r1.left := 72; r1.top := 200; //radio 2 r2 := TRadioButton.Create(Form1); r2.left := 72; r2.top := 240; //radio 3 r3 := TRadioButton.Create(Form1); r3.left := 72; r3.top := 280; r2.selectionState := ssSelected; end; Tim Young Elevate Software www.elevatesoft.com |
Thu, Jan 7 2016 12:55 PM | Permanent Link |
Raul Team Elevate | On 1/7/2016 11:01 AM, Tim Young [Elevate Software] wrote:
> Okay, I looked into it, and the issue is that you guys are forgetting that the default state is ssIndeterminate. When you create the last radio button, it is created with a selection state of ssIndeterminate, and a group of radio buttons can't have one ssIndeterminate and other non-ssIndeterminate selections, so it forces them *all* to ssIndeterminate. You mean you want us to worry about implementation details > The solution is to not set any selection states until *after* you've created all of the radio buttons for the group: Sounds good and makes logical sense. If you haven't already this note would be nice to have in manual also - i have a felling i will run into this again in the future : http://www.elevatesoft.com/manual?action=viewcomp&id=ewb2&comp=TRadioButton Raul |
Thu, Jan 7 2016 1:08 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Raul,
<< You mean you want us to worry about implementation details >> *Your* implementation details, not mine. But, having said that, I noticed a similar issue with radio buttons dropped on a form at design-time. The whole process of creating them and attaching them into the parent causes the first radio button to always be selected, even if you selected the *second* radio button at design-time. *That* is an issue that I need to worry about. << If you haven't already this note would be nice to have in manual also - i have a felling i will run into this again in the future : >> I'll add a note. Tim Young Elevate Software www.elevatesoft.com |
Thu, Jan 7 2016 2:10 PM | Permanent Link |
Tim Young [Elevate Software] Elevate Software, Inc. timyoung@elevatesoft.com | Raul,
Okay, in the process of fixing the design-time/loading issue for the radio buttons, I went ahead and changed the behavior and will note it in the breaking changes for the next build/release. Now you have to explicitly set *all* radio buttons' SelectionState properties to ssIndeterminate in order for the "group" state to be considered "indeterminate". IOW, when you set a button's SelectionState to ssIndeterminate, it bypasses the selected/unselected toggling logic and just sets the state to "indeterminate". This avoids the whole issue of setting one radio button's SelectionState to ssIndeterminate and having all of the buttons set accordingly. It *does* mean that you could end up with a mix of selected, unselected, and indeterminate buttons at design-time or run-time. But, that can only occur programmatically, so it's up to the developer to make sure that it doesn't happen. Still not 100% clear, but better than before. Tim Young Elevate Software www.elevatesoft.com |
This web page was last updated on Friday, November 1, 2024 at 07:01 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |