haruhi4 it all sounds like a cannon for a fly. There are many (more simple) ways to make a button active or not. Let me point few from the top of my head:
1. Create "isClickable" instance variable for the button. Switch value between 0/1 whenever you want to enable or disable buttons functionality (you can do the same for the whole family of buttons). Then your condition should be
"onClick on button AND button.isClickable = 1" => do something.
2. You can surely do the same with the layer visibility condition if you have whole popup on one layer, so it would be:
"onClick on button AND popupLayer is visible" => do something.
3. You might also want to create whole popup functionality within one group, then you can simply activate or deactivate the gorup which will enable or disable "onclick" functionality you put there.