awakefromnib not beng called

Hi,

applescriptobjc newbie here. I’ve looked through all the examples here using awakefromnib, and still can’t seem to get my testscript to run. The simple script (below) is supposed to just grab three text entries and concatenate them into an output box. That part works. However, if I want a default value in one of those text boxes, I thought I could just use the awakefromnib call to do that. However, my awakefromnib never gets called. Even the simple display dialog won’t appear. So it’s not getting called. Any thoughts on what my mistake is?
Thanks very much for your thoughts on this.

Carl


– AutoTiddlywikiAppDelegate.applescript
– AutoTiddlywiki

– Created by Carl Casca on 7/10/11.
– Copyright 2011 MyCompanyName. All rights reserved.

script AutoTiddlywikiAppDelegate
property parent : class “NSObject”

property textInput1 : missing value
property textInput2 : missing value
property textInput3 : missing value
property textOutput : missing value
property aWindow : missing value

on awakeFromNib_()
    textInput1's setStringValue("mesage1")
    display dialog ("message2")
    aWindow's makeFirstResponder()
end awakeFromNib

on userGo_(sender)
    set textInput1String to textInput1's stringValue() as string
    set textInput2String to textInput2's stringValue() as string
    set textInput3String to textInput3's stringValue() as string
    
    set tempvar to textInput1String & textInput2String & textInput3String

– display dialog tempvar
textOutput’s setString_(tempvar)
end userGo_

on applicationWillFinishLaunching_(aNotification)
	-- Insert code here to initialize your application before any files are opened 
end applicationWillFinishLaunching_

on applicationShouldTerminate_(sender)
	-- Insert code here to do any housekeeping before your application quits 
	return current application's NSTerminateNow
end applicationShouldTerminate_

end script

Hi,

awakeFromNib doesn’t have a parameter so there is no underscore character


awakeFromNib()

Thank you for the fast reply! I did try that one both ways as there’s another post on macScripter that discusses that issue. Either with or without the underscore, the awakeFromNib just doesn’t get called.

Is there something I’m supposed to do in the xib file with pointing some outlet etc to something in the script file?
I added that aWindow part in an attempt to follow one of the other posts here and then linked that in the xib file.
But still no joy. Any other ideas on this? I know it’s supposed to be easy, I’m just new to this.

Carl.

Well the first thing to determine if a handler is called or not is simply ad a log so you can see in your console if it is working or not. Then when you see a log it probably doesn’t work because setStringValue does has a parameter so it needs to be setStringValue_(“Hello World!”).

It is quite easy to know when you need an underscore or not. If in the cocoa documentation the method ends with a ‘:’ it means you need an underscore. If it doesn’t you also don’t need one.

Wow, thanks to you both for the quick and very helpful replies! It now works! Thanks!

-carl.

---- updated (working) code is posted below in case it might be useful to others --------


– AutoTiddlywikiAppDelegate.applescript
– AutoTiddlywiki

– Created by Carl Casca on 7/10/11.
– Copyright 2011 MyCompanyName. All rights reserved.

script AutoTiddlywikiAppDelegate
property parent : class “NSObject”

property textInput1 : missing value
property textInput2 : missing value
property textInput3 : missing value
property textOutput : missing value

on awakeFromNib()
    textInput1's setStringValue_("mesage1")

– display dialog (“message2”)
end awakeFromNib

on userGo_(sender)
    set textInput1String to textInput1's stringValue() as string
    set textInput2String to textInput2's stringValue() as string
    set textInput3String to textInput3's stringValue() as string
    
    set tempvar to textInput1String & textInput2String & textInput3String

– display dialog tempvar
textOutput’s setString_(tempvar)
end userGo_

on applicationWillFinishLaunching_(aNotification)
	-- Insert code here to initialize your application before any files are opened 
end applicationWillFinishLaunching_

on applicationShouldTerminate_(sender)
	-- Insert code here to do any housekeeping before your application quits 
	return current application's NSTerminateNow
end applicationShouldTerminate_

end script