- This topic has 6 replies, 2 voices, and was last updated 10 years ago by JohnG.
-
AuthorPosts
-
October 30, 2014 at 4:05 pm #36346JohnGParticipant
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
November 3, 2014 at 10:58 am #52694SupportKeymasterHello, 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…
November 4, 2014 at 7:57 pm #52706JohnGParticipantQuote: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
November 10, 2014 at 12:38 pm #52713SupportKeymasterI 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.
November 11, 2014 at 12:31 am #52718JohnGParticipantHello,
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]
November 11, 2014 at 7:20 am #52721SupportKeymasterI 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).
November 14, 2014 at 8:08 am #52730JohnGParticipantThankyou! 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
-
AuthorPosts
- You must be logged in to reply to this topic.