'Browse' button

Find out why the . goes before the /

Moderator: Paul Tuersley

Post Reply
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

March 9th, 2007, 6:57 pm

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.
zold

March 9th, 2007, 11:29 pm

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
slawes
Posts: 25
Joined: December 9th, 2006, 12:38 pm
Location: LA, California

March 12th, 2007, 10:02 am

Thanks Chris, that worked.
Offcourse, the question would be why - seems kind of random.

Thanks,
Stephen.
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: Seattle, WA
Contact:

March 12th, 2007, 7:42 pm

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
zold

March 12th, 2007, 9:57 pm

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
User avatar
redefinery
Posts: 112
Joined: April 1st, 2005, 8:16 pm
Location: Seattle, WA
Contact:

March 12th, 2007, 10:04 pm

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
Post Reply