Greetings:
I am hard at work on my first AS Studio project. Please feel free to comment on any and all parts listed below. I have read this recent thread: http://bbs.applescript.net/viewtopic.php?id=17905 about getting data back out of a panel window, but even with the boxes checked on both windows (main and newDate), it will not work. What I am trying to accomplish is a main window with a date printed that has three buttons; one to advance the date by one day, one to move back one day, and one to enter in a user defined date. The first two buttons work famously, and the date advances and retracts nicely. However, even though the new date panel comes down and accepts data input, nothing in the panel ended handler is being called.
Here is the script so far:
global to_day
property datePanel : missing value
on awake from nib theObject
set to_day to (current date)
my ShowDate(0)
end awake from nib
on clicked theObject
if datePanel is equal to missing value then
load nib "datePanel"
set datePanel to window "newDate" --This appears to replace the [missing value] in the panelWIndow property with the name of the panel window
end if
(*Add your script here.*)
if name of theObject = "nextDate" then
my ShowDate(1)
else if name of theObject = "back" then
my ShowDate(-1)
else if name of theObject = "new" then
display panel datePanel attached to window "main"
end if
end clicked
--This next section does not seem to be working. I cannot get the data back from the panel window at all.
on panel ended datePanel with result theResult
if theResult is 1 then
tell datePanel
set new_Month to contents of text field "month"
set new_day to contents of text field "day"
set new_year to contents of text field "year"
end tell
display dialog new_Month & space & new_day & space & new_year
set to_day's month to new_Month
set to_day's day to new_day
set to_day's year to new_year
my ShowDate(0)
end if
end panel ended
-------------------------------
to ShowDate(p)
set to_day to (to_day + (p * days))
set contents of text field "dateView" of window "main" to date string of to_day --Remember to reference the window as well
end ShowDate
I appreciate any input at all on this; I am happy to learn anything helpful.