Sunday, December 17, 2017

#1 2017-11-26 02:13:51 pm

cudaboy_71
Member
Registered: 2014-03-04
Posts: 20

radio buttons not toggling between choices

Here's a quick 4 minute video of me trying to build a simple set of two radio buttons with a choice of 'Left' and 'Right', which fails. I do add in a button to display a dialog box, which confirms I'm actually passing the value of the button clicked back to the applescript. I just can't get the radio buttons to toggle as expected.

https://youtu.be/JpEuSAnmSgU

Can someone tell me what I'm doing wrong? This method works fine for checkboxes. I'm just missing the bit that culls the radio buttons in to a group so that when one is selected the other is deselected.

Bonus round: What' I'd really like to do is pass the title of the radio button back to the variable; in this case that would be 'Left' or 'Right' depending on which button is clicked. But, I'm happy with making baby step progress.

Offline

 

#2 2017-11-26 06:19:17 pm

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

Re: radio buttons not toggling between choices

The buttons must belong to the same view, and call the same action handler.


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

Offline

 

#3 2017-11-26 07:44:26 pm

cudaboy_71
Member
Registered: 2014-03-04
Posts: 20

Re: radio buttons not toggling between choices

[final edit]

ok, finally poked in the dark long enough to figure it out.

the buttons were already in the same view. so, check that box off.

I needed to create an action handler, as Shane suggested. So, I created:

Applescript:


on radioClicked_(sender)
set modifierReceived to sender's title as string
end radioClicked_

the tricky bit was getting the title back from the button sent. that bit of verbage took a minute to suss out.

But, now It's working great. Thanks.

Last edited by cudaboy_71 (2017-11-26 09:26:19 pm)

Offline

 

#4 2017-11-26 09:25:17 pm

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

Re: radio buttons not toggling between choices

You're getting the sender's title in the handler, so you probably don't need to use a binding -- it's redundant.


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

Offline

 

#5 2017-11-26 09:27:00 pm

cudaboy_71
Member
Registered: 2014-03-04
Posts: 20

Re: radio buttons not toggling between choices

i think we were posting the same thing at the same time. see my edit above. thanks for your help.

Offline

 

#6 2017-11-26 10:00:28 pm

cudaboy_71
Member
Registered: 2014-03-04
Posts: 20

Re: radio buttons not toggling between choices

[edit] nvm

must have been a bug somewhere. i recreated the app from scratch and it works fine.

Last edited by cudaboy_71 (2017-11-26 10:06:41 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)