Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to connect a button's Sent Action in Xcode for a custom Automator Action project

I'm in the Interface Builder of Xcode, creating an Cocoa-Applescript custom Automator Action. I have a Button and a ComboBox menu in the interface. I'd like to fill the content values of the ComboBox's menu when the user clicks the Button. I've created the

on buttonSentAction_(sender)
    -- set popupMenuContentValues of my parameters() to aList as list
    my popupMenu's addItemsWithObjectValues_(aList)
end buttonSentAction_

handler in the applescript file, but when I ctrl drag from the button to the File's Owner, the File's Owner does not highlight for me to drop the connection. What I'm expecting is for it to drop and give me the option of choosing the buttonSentAction_ handler to receive the sent action. If I right-click on File's Owner, the received action handler I've created in the Applescript controller file does not show up. (Note, I'm still unsure about the correct line to populate the ComboBox Menu inside that handler, too.) Screen Grab of linking combobox to File's Owner

I can see in the "FM to Named Text Boxes" sample Automator Action project at macosxautomation.com has a button in the IB where you can see in the Bindings Inspector that the button's sent action is in fact connected to the File's Owner, and that the applescript file has that matching handler. Also, I the controller for File's Owner is by default set to the applescript file. I'm missing something specific about hooking up sent actions in an Automator Action Project, obviously. Any help?

like image 634
jweaks Avatar asked Nov 22 '22 20:11

jweaks


1 Answers

Update: I got it to work. The key was that you have to create an Outlet for the object before you can then bind to a Sent Action Handler.

I deleted the button and started over, with a new naming scheme. This time, the File's Owner received the drag, and everything connected to the sent action and it works as expected. I did things exactly as I had before, so it is a mystery why the first action handler could not receive the Sent Action in IB.

Sample Code below:

on searchTypeMatrixWasClicked_(sender)
    -- called with the matrix sent action
    set theIndex to (actionTypeIndex of my parameters()) as integer
    if theIndex is 0 then
    -- do stuff, etc.
    else if theIndex is 1 …
    end if
end

Bindings Inspector in IB

like image 163
jweaks Avatar answered Dec 06 '22 09:12

jweaks