@boomzilla said:
@Khalin said:I agree with blakeyrat. When you set a property it means that you want to do something with it, it's not like "I want to set it for the future". The Visible property means that you want the control to be visible or not. It's like real life. Taking again the example of the box. if you want to show the item inside the box you MUST show the box first and the you CAN show the item inside the box, never before. MS is doing the right thing in here. if the control is not visible then the property need to return false because doesn't matter how you look at it, the control is NOT visible
But then, if you can call setVisible(true) (without getting an exception) when the parent isn't visible, by this logic, shouldn't that force the parent to suddenly become visible? The issue here is that something is exposed that looks like simple setters / getters, but is really a lot more complex, and so is easy to confuse.
As others have pointed out, there are two bits of information here: 1) is this widget actually being shown in the UI and 2) should this widget be visible when its parent is being shown in the UI. There are legitimate arguments on both sides, and both are going to confuse people. I think the Delphi way of dealing with this is pretty sensible.
Well.. I think that depends on the point of view. In .Net the properties are fields which can include code in setters/getters which means they are "unpredictable". I think I need to explain that. with unpredictable I mean that the setter/getter method can depend on the context (that's the case I think we are dealing with). In my opinion a child cannot be visible and cannot force the parent to be visible. Same case happens with the DOM (taking one example said above), if you have a hidden DIV which contains another hidden DIV, the parent will now be set to visible when you set the child to visible, and the child will not be set to visible when you set the parent to be visible. probably there should be another property which says if the control has the Visible field set to true/false but as i said, it's a property, not a field...