Page 1 of 1

'Browse' button

Posted: March 9th, 2007, 6:57 pm
by slawes
I have this script that has a really simple UI with a checkbox and a browse box for entering a file location.
It works fine on a mac, but the browse button is seemingly disabled on the pc. The weird thing is that the 'ok' and 'cancel' buttons work fine.
What gives ?

function buildUI() {
if (win != null) {
win.OutputFolder = win.add('statictext', [31,80,181,120], 'Maya frame counter:');
win.mayacheck = win.add('checkbox', [190,80,210,100], '');
win.mayacheck.value = true;
win.OutputFolder = win.add('statictext', [31,130,131,190], 'Import Folder:');

win.filelocation = win.add('edittext', [143,130,403,190], '', {multiline: true});
win.varspnl = win.add('panel', [20,35,530,210], 'Variables');
win.Browse = win.add('button', [416,130,496,150], 'Browse', {name:'Browse'});
win.Browse.onClick = function () {
var defaultFolder = this.parent.filelocation.text;
targetFolder = folderGetDialog("Import Folder");

if (targetFolder != null)
this.parent.filelocation.text = targetFolder.fsName;
}
win.cancel = win.add('button', [21,220,101,240], 'Cancel', {name:'Cancel'});
win.cancel.onClick = function () {this.parent.close(1)};
win.ok = win.add('button', [450,220,530,240], 'OK', {name:'OK'});
win.ok.onClick = function () {


I can post more of the script if needed.
Thanks for any help.
-Stephen.

Re: 'Browse' button

Posted: March 9th, 2007, 11:29 pm
by zold
Off the top of my head, I'd suggest commenting out the panel part and see if the button comes back on a pc. On Windows panels can screw up some control items, unfortunately.

cg

browse

Posted: March 12th, 2007, 10:02 am
by slawes
Thanks Chris, that worked.
Offcourse, the question would be why - seems kind of random.

Thanks,
Stephen.

panel obscured other controls

Posted: March 12th, 2007, 7:42 pm
by redefinery
Hi zold,

It might be because your panel was defined with a top edge of 35 and bottom edge of 210, which encloses all of the other controls except OK/Cancel (see the top and bottom values for those other controls), and maybe it's getting added after the other controls on Windows for some reason.

Usually if you're creating a panel, you're wanting to add the controls that appear inside it to the panel itself (i.e., win.panel.add(...)). When you do this, coordinates are relative to the panel, not the window, so values would need to adjusted accordingly.

Hope this helps.

Jeff

Re: panel obscured other controls

Posted: March 12th, 2007, 9:57 pm
by zold
Hi Jeff,
Your reply was meant for slawes a.k.a. Stephen, actually, but I believe I have created UIs in the manner described and still had Windows bug out the interface. This is why (I thought?) I had to put a no-panel version of one of my scripts on my webpage.
Maybe I am mistaken (oh, I am feeling so lazy about being scientific about this at 1 in the morning ... )

Chris G a.k.a. zold
redefinery wrote:Hi zold,

It might be because your panel was defined with a top edge of 35 and bottom edge of 210, which encloses all of the other controls except OK/Cancel (see the top and bottom values for those other controls), and maybe it's getting added after the other controls on Windows for some reason.

Usually if you're creating a panel, you're wanting to add the controls that appear inside it to the panel itself (i.e., win.panel.add(...)). When you do this, coordinates are relative to the panel, not the window, so values would need to adjusted accordingly.

Hope this helps.

Jeff

Posted: March 12th, 2007, 10:04 pm
by redefinery
Hi Chris (zold)...

Oops, was looking at the wrong message when replying.

I guess I never use a panel unless I'm adding the controls within them. Similar for group controls. Both are containers for other controls.

Jeff