PDA

View Full Version : Dynamically access all controls within a window instance



phantomwhale
December 18th, 2010, 05:00
Hi,

Is there a simple method to loop over all the controls within a window instance ? For instance, if I wanted to set a label, number and string field invisible, I can currently say :


function show(bool)
label.setVisible(bool)
numberField.setVisible(bool)
stringField.setVisible(bool)
end

But is it possible to write something like :


function show(bool)
for windowControl in sheetdata do
windowControl.setVisible(bool)
end
end

My reason for trying this is I am trying to set a cluster of controls to be visible or invisible all based on a database node value, and currently the method I was trying was to put them all within a subwindow, and then the window can switch itself on and off as it decides. However, I just discovered that the windowinstance object has no "setVisible" method, hence I was at least hoping to access the window's "sheetdata" elements dynamically, otherwise there really is no reason to have them all in a subwindow in the first place...

Hopefully that's semi-clear !
Ben

phantomwhale
December 18th, 2010, 06:07
Clearly, after 5 mins away from the code, the answer was to toggle the subwindow visibility in a script in the subwindow declaration, rather than trying to do it in the window class definition I am using in the subwindow.

Still intrigued to know if there is a list / array of the window controls in a window instance though.

StuartW
December 18th, 2010, 10:51
I'm not aware of any windowcontrol collection, it certainly would be useful though.