No way to check if a component is a radio button in the Wizardform.ComponentsList

50 views
Skip to first unread message

A

unread,
Apr 30, 2024, 12:46:49 AMApr 30
to innosetup
There seems to be no way to know if a component belongs to a radio button. This is important because trying to uncheck a radio button through code causes the parent to lock up and fail to uncheck as well during that same method call. Normally, we could just check if it's a radio and avoid it, but there's no where to check in code.

Eivind Bakkestuen

unread,
Apr 30, 2024, 1:15:05 AMApr 30
to inno...@googlegroups.com
Provide code you have tried, and a full description of what you are trying to do, and alternatives can be provided?

On Tue, Apr 30, 2024 at 2:46 PM A <k95...@gmail.com> wrote:
There seems to be no way to know if a component belongs to a radio button. This is important because trying to uncheck a radio button through code causes the parent to lock up and fail to uncheck as well during that same method call. Normally, we could just check if it's a radio and avoid it, but there's no where to check in code.

--
You received this message because you are subscribed to the Google Groups "innosetup" group.
To unsubscribe from this group and stop receiving emails from it, send an email to innosetup+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/innosetup/b31d5da4-4133-4fa1-a790-8c4649be3daan%40googlegroups.com.

Gavin Lambert

unread,
Apr 30, 2024, 1:17:15 AMApr 30
to innosetup
On Tuesday, April 30, 2024 at 4:46:49 PM UTC+12 A wrote:
There seems to be no way to know if a component belongs to a radio button. This is important because trying to uncheck a radio button through code causes the parent to lock up and fail to uncheck as well during that same method call. Normally, we could just check if it's a radio and avoid it, but there's no where to check in code.

Do you have a MCVE of your issue?  I tried a quick test and all that happened is that it didn't uncheck anything, which is reasonable because there must always be one selection in an exclusive group.  If you want to uncheck them all, then uncheck the parent instead (or if the parent is also exclusive, then check one of its siblings).

But in any case, the components are defined by the same script that contains the code to manipulate them -- you should know which components are exclusive or not already.

This also makes me wonder if you actually have an XY problem.  What is the original goal that you're trying to solve with this?  Maybe there's a better way to do it. 

A

unread,
Apr 30, 2024, 10:00:27 AMApr 30
to innosetup
Thank you all so much for your aid, you two. Allow me to explain my use case. I'm currently using Inno Setup as a modding ecosystem installer for a particular game. The issue with this game is that it currently has three concurrent editions that can use many of the same components as the others, but others included will cause a problem. To remedy this, when the path for the game is provided, I retrieve the versions and make changes to the component list in order to avoid incompatible components from being installed. I do this by keeping an array of string with the incompatible components per-version that lists their descriptions. This has worked well, but I recently made changes and have encountered the radio button issue.

For example, I have the following components defined:

Name: ModExt; Description: Modding Extensions;
    Name: ModExt/MaidLoader; Description: MaidLoader; Flags: exclusive; Types: full compact;
    Name: ModExt/modloader; Description: ModLoader; Flags: exclusive;

During runtime, when the page changes to the components, or when the type combo changes, I pass my array of string with the aforementioned incompatible components to the following method:

procedure RemoveComponents(components: Array of string);
var
M, I: Integer;
begin

    for M := Wizardform.ComponentsList.Items.Count - 1 downto 0 do
    begin

        for I := 0 to (GetArrayLength(components)-1) do
        begin
            if (CompareText(Wizardform.ComponentsList.ItemCaption[M], components[I]) = 0) then
            begin
               
                Log('Disabling ' + Wizardform.ComponentsList.ItemCaption[M] + ' Checked: ' + IntToStr(Integer(Wizardform.ComponentsList.Checked[M])))

                if Wizardform.ComponentsList.Checked[M] = true AND Wizardform.ComponentsList.CheckItem(M, councheck) = false then
                    Log('Failed to uncheck ' + Wizardform.ComponentsList.ItemCaption[M] + '!');

                Wizardform.ComponentsList.ItemEnabled[M] := false;              
                break;

            end;
        end;

    end;

end;

However, the following occurs instead exclusively where the radio button is involved.:

COM_Modular_Installer_2.5.22.tmp_UOnhLiw9AC.png

And my logging code reports the parent indeed could not be unchecked:

[09:53:20.242]   Disabling ModLoader Checked: 0
[09:53:20.246]   Disabling MaidLoader Checked: 1
[09:53:20.249]   Failed to uncheck MaidLoader!
[09:53:20.253]   Disabling Modding Extensions Checked: 1
[09:53:20.254]   Failed to uncheck Modding Extensions!

I've entertained the idea of making another method that only disables and feeding it the radio buttons instead, but this seemed kind of odd to me that the radio buttons react this way and that there's just no way to check if they're radio either. Normally it wouldn't matter, but for some reason I can't uncheck the parent when this occurs.

A

unread,
Apr 30, 2024, 10:27:03 AMApr 30
to innosetup
Hmm, actually I may not fully understand this issue. Running the above loop in descending order, not ascending order, works fine on the initial page change, but when changing the type combo box it completely fails to uncheck again, along with a few other components failing to uncheck for some reason that work fine when doing the loop as originally.

A

unread,
Apr 30, 2024, 3:39:22 PMApr 30
to innosetup
Sorry to hit this topic again but I figured out the issue. If a radio button is disabled/grayed, the check box parent cannot be unchecked. Since my loop works from bottom to top, the radio children were being disabled and the parent would then lock up.

My solution was to enable all components before unchecking them, and then when unchecks are done, handle disabling again in a follow-up loop.
Reply all
Reply to author
Forward
0 new messages