1. I have 3 checkbuttons and a label. The 3 choices are Red, Blue, and None. I want only one to be selected at a time. When one checkbutton is selected, pressing it again should have no effect. When one of the other buttons is pressed, the original selection is then unchecked and the label color changes accordingly. I found that the checkbuttons will deselect when pressed a second time, so after some research, I thought I could lock and unlock them using the SetButtonState() function. When the program variables set the checkbuttons, during the OnShow(), all works as planned. The label is the proper color and the selected checkbutton is locked in the checked position. Here is the code that accomplishes the setting and locking of the Red checkbutton (box[3]):

        elseif(ASPECT.FrameOpt[aspName].Color == "Red") then
            r, g, b = 1, 0, 0;
            Aspect[panelName].box[1]:SetButtonState("NORMAL")
            Aspect[panelName].box[1]:SetChecked(false);
            Aspect[panelName].box[2]:SetButtonState("NORMAL")
            Aspect[panelName].box[2]:SetChecked(false);
            Aspect[panelName].box[3]:SetChecked(true);
            Aspect[panelName].box[3]:SetButtonState("NORMAL", true)
        else
    

    The color attributes set the label color at the end of the block.

    Now when I push the Blue checkbutton, it does not lock nor does the Red checkbutton unlock. Even more curious, the label color is not changed. All worked properly before the introduction of the SetButtonState() was added to lock the buttons. Here is the OnClick code for the Blue checkbutton (box[2]):

        Aspect[panelName].box[2]:SetScript("OnClick", 
        function()
            ASPECT.FrameOpt[aspName].Color = "Blue";
            Aspect[panelName].fontstring[3]:SetTextColor(0, 0, 1, 1.0);
            Aspect[panelName].box[1]:SetButtonState("NORMAL")
            Aspect[panelName].box[1]:SetChecked(false);
            Aspect[panelName].box[2]:SetChecked(true);
            Aspect[panelName].box[2]:SetButtonState("NORMAL", true)
            Aspect[panelName].box[3]:SetButtonState("NORMAL")
            Aspect[panelName].box[3]:SetChecked(false);
        end
        );
    

    The label color is changed before the checkbuttons are addressed, yet it doesn't change. It did fine prior to the addition of the SetButtonState() function to lock and unlock the checkbuttons.

    I have no idea why this is not working properly. I changed the unlock SetButtonState() functions before the SetChecked(), just to be certain the SetChecked would not be locked out, and I set the SetButtonState() locking AFTER the SetChecked() on checkbuttons that I know to be unlocked, so the SetChecked() would take affect before they were locked.

    The checkbuttons are using the ChatConfigCheckButtonTemplate. Could that be a problem? Is there another template I should be using?

    Any clue why this is not working as planned and desired?

  2. I decided that since the OnShow did the work fine, perhaps the button has to be rewritten. I thought since they changed images, that a rewrite was done. Perhaps I need an OnUpdate or a Hide and Show sequence. Since I am already setting the buttons manually, perhaps an OnUpdate instead of an OnClick. Should I place an OnClick to change the variables represented by the buttons and then having the ParentFrame do an OnUpdate calling the function that sets the checkbuttons during an OnShow. The label was changing colors before I began the SetButtonState() method, so I had assumed there was a redraw occurring.

    edit 1503 PDT:

    I also realized that I only run the OnShow when the Parent of the checkbutton's Parent is run. I am going to add an OnShow to each checkbutton Parent, then begin using OnUpdate for the Frames starting with the Parent Frames and working down to the checkbuttons.

    edit 1640 PDT:

    The OnShow and OnUpdate additions locked all of the buttons so they would not interact. I decided that I would try using EnableMouse() for the checkbutton frames to keep them from being unchecked without another selection being made. I removed the additional OnShow and OnUpdate functions and tested out the EnableMouse() abilities. All checkbuttons are locked out and do not react to the mouse, even when they are EnableMouse(true).

  3. Not sure there's really a question in here. The problem, as I understand it is:

    You have three checkboxes, and a single FontString. Only one of the checkboxes should be selected at any given time, and once selected should not be able to be unchecked. Whichever box is selected should be displayed in the FontString. The way I'd do this is:

    1. Create a function that examines a value in your addon to determine which checkbox should be checked, and update the frame in this function. Something like:

        function UpdateCheckboxes()
          for idx, checkbox in ipairs(checkboxes) do
            if idx == WhateverCheckboxIndexIsSelected then
              checkbox:SetChecked(true)
              label:SetText("Color name")
              checkbox:Disable()
            else 
              checkbox:SetChecked(false)
              checkbox:Enable()
            end
          end
        end
      
    2. Now just set an OnClick function on each of the checkboxes:

        function Checkbox_OnClick(self)
          WhateverCheckboxIndexIsSelected = self.index
          UpdateCheckboxes()
        end
      

    That's really all you need to do, as far as I can tell. Should get you the behavior you want.

  4. That would simply disable the checkbutton in question. I was trying to avoid having the check mark disabled to the grey color. I had considered (while traveling) that I could change the disabled texture of the checkbutton to match the enable texture. I am also considering using other templates, perhaps a radiobutton, or simply a button. The checkbutton functionality is not core to operation of the buttons and therefore other buttons might even look more appealing. I am a bit concerned that I don't have enough knowledge to understand why the SetButtonState() or the EnableMouse() methods did not work and locked everything down. I suspect that I have introduced something in the code that is causing it to malfunction without them being present. I am in a position now to continue work and will get back on when I find more information. As usual, I won't be able to let it go until I understand why it did no perform to my expectations.

  5. Then change what I have to use SetButtonState instead of Enable/Disable, use NORMAL and locked for when its unchecked, and NORMAL and unlocked when its checked. THe rest of the code should stay the same.

  6. I'll give it a try.

  7. The problem was being caused by a loop variable. When I created the buttons, the a variable was being set by the loop, then used in the OnClick(). The variable behaved erratically because of the varying values it assumed after the OnClick() function was defined. Once I created a variable on the button and set it, using the self.variable in the OnClick(), everything began working properly.

    No wonder it was so difficult to understand the new functions I was using. I wasn't calling them as desired and was feeding them garbage.

    Thank you again for your patience and advice. Sorry it took so long for me to get the time to look at it again and track down the culprit. Fresh eyes I suppose.

  8. No worries! Glad you were able to sort it out!