Interaction between multiple sRadioGroups

Viewing 7 posts - 1 through 7 (of 7 total)
  • Author
    Posts
  • #36346
    JohnG
    Participant

    Hello,

    Related to my previous sSpeedbutton post, I want to use an sRadioGroup to configure whether a Speedbutton acts in Latching or Momentary fashion. But it seems when there are multiple sRadioGroups, there is (unwanted) interaction between them.

    See the attached demo project.

    (the demo is done in DXE2, so the Uses clause includes NameSpace prefixes)

    Do this:

    1) compile and run

    2) go to the Config form, and set all buttons (S1 – S4) to “Latching”,

    and set “Relay” values to something other than None (this enables the buttons).

    3) return to the main form, and you will see the buttons all working in Latching mode.

    4) click the “Show stored…” button, and note the config values displayed

    (these are gotten from the DataModule)

    5) now, return to the Config form. When the Config form opens, it reads config values

    from the DataModule. But what I see is that 3 of the 4 sRadioGroups are now set

    back to Momentary (without any manual/human intervention).

    I think this is a bug?

    John

    #52694
    Support
    Keymaster

    Hello, thank you for the demo.

    I'm not sure where is a reason of the problem, but I see a same behaviour with standard controls.

    Maybe I not quite understand a problem…

    #52706
    JohnG
    Participant
    Quote:

    but I see a same behaviour with standard controls.

    Yes, I see that now. So the problem lies somewhere in the original component.

    Quote:

    Maybe I not quite understand a problem…

    The problem is that the Radiogroup's ItemIndex changes unexpectedly (when there is more than 1 Radiogroup). If I replace the sRadioGroup with sComboBox, then setting/getting config values works as expected. Now, when I set an ItemIndex := 1 it stays as configured.

    I do think the visual presentation using a Radiogroup looks better for this particular case, though. Perhaps you could consider this an opportunity to improve on the original component? 😉

    John

    #52713
    Support
    Keymaster

    I should make an easier test app firstly, because your application has a many code which can have influence.

    I'll try make such application soon.

    #52718
    JohnG
    Participant

    Hello,

    The first demo was more complex than needed. But there was a reason for that: to demonstrate and confirm that my config set/get technique was working correctly — it was, except for the Radiogroups.

    Attached is a stripped-down demo, using only 2 Radiogroups. There is also a Combobox demo attached. Both projects use the exact same code, except for the Radiogroup vs the Combobox on the Config form.

    It's hard to believe that there are such problems with a Radiogroup, after all these years of Delphi development. I would be happy to be shown the error of my ways. 🙂

    John

    [attachment=6953:Radiogroup Test.zip]

    [attachment=6954:Combobox Test.zip]

    #52721
    Support
    Keymaster

    I found a reason of the prob, look this code:

    Code:
    procedure TfrmConfig.GetConfigVals;
    begin
    rgSw1.ItemIndex := dmMyDM.Sw[1]; // Here rgSw1Click called and array is changed. Before – (0,0), after (0, 1)
    rgSw2.ItemIndex := dmMyDM.Sw[2];
    end;

    procedure TfrmConfig.rgSw1Click(Sender: TObject);
    begin
    with dmMyDM do
    begin
    Sw[1] := rgSw1.ItemIndex;
    Sw[2] := rgSw2.ItemIndex;
    end;
    end;

    So, dmMyDM.Sw array is changed when you changes the ItemIndex (because rgSw1Click called).

    #52730
    JohnG
    Participant

    Thankyou! I was stuck in my own view and couldn't see this.

    Not an AC problem, so especially thanks for taking the time to look.

    John

Viewing 7 posts - 1 through 7 (of 7 total)
  • You must be logged in to reply to this topic.