Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Margins around buttons in script panel

Community Beginner ,
Aug 01, 2017 Aug 01, 2017

Hey all,

I can't figure out why margins are not working between the buttons in the panel I've created. They only work around the outside. Is margins the correct property to be tweaking?

Ideally, I'd like between 1-2px but it looks like it is stuck at 10px. Any pointers in the right direction would be much appreciated I'd played around with the bounds property instead of size but that didn't work either.

Here is a simplified version of the script:

//begin script

function myScript(thisObj) {

    var myPanel = (thisObj instanceof Panel) ? thisObj : new Window("palette", "Test", undefined, {

        resizeable: true,

        orientation: 'column',

    });

    myPanel.spacing = 1;

    myPanel.margins = 2;

    var btnSize = [30, 30];

    var btnGrp = myPanel.add('group', undefined);

    btnGrp.orientation = 'row';

    var btn1 = btnGrp.add('button', undefined, '01');

    btn1.size = btnSize;

    var btn2 = btnGrp.add('button', undefined, '02');

    btn2.size = btnSize;

    var btn3 = btnGrp.add('button', undefined, '03');

    btn3.size = btnSize;

    var btn4 = btnGrp.add('button', undefined, '04');

    btn4.size = btnSize;

    myPanel.layout.layout(true);

    if (myPanel instanceof Window) {

        myPanel.show();

    } else {

        myPanel.layout.layout(true);

    }

    myPanel.layout.resize();

    myPanel.onResizing = myPanel.onResize = function() {

        this.layout.resize();

    }

}

myScript(this);

//end of script

TOPICS
Scripting
2.2K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Advocate , Aug 01, 2017 Aug 01, 2017

Well, "button" does not have "margins" property, so you cannot adjust those.

To accomplish what you need, to have to tweek groups spacing those button are in.

var btnGrp = myPanel.add('group', undefined);

btnGrp.spacing = 2;

Translate
Advocate ,
Aug 01, 2017 Aug 01, 2017

Well, "button" does not have "margins" property, so you cannot adjust those.

To accomplish what you need, to have to tweek groups spacing those button are in.

var btnGrp = myPanel.add('group', undefined);

btnGrp.spacing = 2;

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2017 Aug 02, 2017

Hey Tomas! Thanks for replying! This has definitely helped as they are now closer together. Although not as close as I'd of hoped.

Even with ".spacing = 0" or at a negative value there is still a gap between each button. Ideally, I'd like there to be almost no gap between the buttons. See image below. The top is what I'm getting, the bottom is what I'm trying to achieve:

ButtonSpacingExample.png

Were you able to get them any closer together? or are they any other ways to reduce the spacing between them?

Thanks again!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Engaged ,
Aug 02, 2017 Aug 02, 2017

btnGrp.spacing=btnGrp.margins=0;

works fine for me, could be a mac default to leave a pixel between items. There seems to be a pixel or two minimum by default to fit in a panel or window. On PC the buttons stack perfectly beside eachother.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Advocate ,
Aug 02, 2017 Aug 02, 2017

Witch AE version are you using? AE 2017.2 on mac gives such results with your script with btnGrp.spacing = 0;

Screen Shot 2017-08-02 at 12.11.36.png

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Aug 02, 2017 Aug 02, 2017
LATEST

Doh! Major fail on my side. I had only been running it in ExtendScript and hadn't tested it in After Effects yet. It is working perfectly there...

Didn't know there would be a difference aha. Thanks a lot guys!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines