pguardiario
pguardiario

Reputation: 55002

XCode 10 adding action to button

I'm trying to make a Cocoa app with buttons that run simple command line scripts.

I can't seem to figure out how to add the action to my button.

I've read some docs that suggest holding down option and dragging the button into controller code but I think they are out of date.

Can someone suggest how to get there from this screenshot?

enter image description here

Upvotes: 1

Views: 8504

Answers (2)

Peter Mattheisen
Peter Mattheisen

Reputation: 177

Actually I had the same problem and the root cause was just the drag method. From the descriptions I had assumed that I need to press CTL and then drag while having the left mouse button pressed. This did not work at all (in my environment). Then I noticed that "it works" with the right mouse button. But the result was not correct. (E.g. I could not get "Action"). Finally I found: I have to use the right mouse button only for dragging without holding CTL. Then I got the correct result.

Upvotes: 0

MultiColourPixel
MultiColourPixel

Reputation: 1232

You need to first select your button, then hold the control ⌃ button on your keyboard and then drag that across to your view controller. That will then give you the option of what to name your method etc.

enter image description here

Upvotes: 8

Related Questions