Wednesday, September 18, 2019

#1 2019-09-10 11:50:01 am

markconwaymunro
Member
Registered: 2017-11-28
Posts: 37
Website

Change width of a popup button programmatically

I have a popup button that I want to shrink the width under certain circumstances. After googling for an hour I can't seem to find a good example of how to do this. Is such a thing possible... and easy?

Offline

 

#2 2019-09-13 01:38:03 am

technomorph
Member
Registered: 2017-12-14
Posts: 118

Re: Change width of a popup button programmatically

Create a button variable and connect via IB

aButton
aButton.width = 80

aButton’s setWidth:80

Offline

 

#3 2019-09-13 12:43:37 pm

markconwaymunro
Member
Registered: 2017-11-28
Posts: 37
Website

Re: Change width of a popup button programmatically

Thanks. However:

Applescript:

aButton's setWidth:80

Returns: Expected end of line, etc. but found unknown token. (-2741)

Offline

 

#4 2019-09-13 05:30:06 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5894

Re: Change width of a popup button programmatically

Assuming you're not using autolayout, you can use either setFrame: or setFrameSize:.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/
latenightsw.com

Offline

 

#5 2019-09-13 11:25:23 pm

technomorph
Member
Registered: 2017-12-14
Posts: 118

Re: Change width of a popup button programmatically

markconwaymunro wrote:

Thanks. However:

Applescript:

aButton's setWidth:80

Returns: Expected end of line, etc. but found unknown token. (-2741)




So I was wrong.   Shane’s answer below will do it.
You may have to get the current height via accessing the frame size first
Unless you know the height.  Which you could also reference from IB ruler / size tab.

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)