Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

AppleScript Studio: status bar and panel window

My problem is that the panel won't open, and so I don't see the progress bar.
All I am looking for is the panel to come down, show the progress bar turning, then for the panel to go away when iCal is done adding the event. This is the entire script, but I'm not sure I have everything right in Interface builder. The Documentation for display mentioned clicking panel ended, but then further down it looked like you didn't need it.

I'm confused.

----
-- +Event.applescript
-- +Event

-- Created by Michael Ewald on 6/26/06.
-- Copyright 2006 Michael Ewald. All rights reserved.

load panel "statusPanel" from nib "statusPanel"

on clicked theObject
-- Get & Format form items
set eventTitle to contents of text field "eventTitle" of window "main" as string
set eventLocation to contents of text field "eventLocation" of window "main" as string
set EventNotes to contents of text view "eventNotesText" of scroll view "eventNotesScroll" of window "main"
set allDay to state of button "allDay" of window "main"

set startDate to current date
set startDate to content of control "startDate" of window "main"
set endDate to content of control "endDate" of window "main"

-- Make Event
start progress indicator "statusBar" of window "statusPanel"
try
start progress indicator "statusBar" of window "statusPanel"
display "statusPanel" attached to window "main"

tell application "iCal"
set theCalName to "AppleScript Test"
set theCal to calendar theCalName
if allDay is equal to 1 then
make new event at end of calendar theCalName with properties {summary:eventTitle, location:eventLocation, allday event:true, description:EventNotes}
else if allDay is equal to 0 then
make new event at end of calendar theCalName with properties {summary:eventTitle, location:eventLocation, start date:startDate, end date:endDate, description:EventNotes}
end if
end tell
-- reset form
set the contents of text field "eventTitle" of window "main" to ""
set the contents of text field "eventLocation" of window "main" to ""
set contents of text view "eventNotesText" of scroll view "eventNotesScroll" of window "main" to ""
set state of button "allDay" of window "main" to 0

set currentDate to current date
set currentDatePlus to (current date) + 1 * hours

-- Update Times
set content of control "startDate" of window "main" to currentDate
set content of control "endDate" of window "main" to currentDatePlus

on error
display alert "There was a problem!"
end try
close panel "statusPanel"
end clicked
----

MacBook Pro 15" 2.16 ghz, Mac OS X (10.4.6)

Posted on Jun 28, 2006 11:36 PM

Reply
6 replies

Jun 29, 2006 9:53 AM in response to Michael Ewald

In that case,

load panel "statusPanel" from nib "statusPanel"


the above line does nothing, it isn't in any handler. You could remove it, you don't need to load it if you built it in MainMenu.nib.


display "statusPanel" attached to window "main"


that won't work, because you didn't specify the object class.
although you think of "statusPanel" as a panel, but in XCode, panel is window class. so you can do:

display window "statusPanel" attached to window "main"

to dismiss it you have to use hide command:

hide window "statusPanel"

Jun 29, 2006 10:38 AM in response to Cyclosaurus

Thanks for the response,

right now the window is in a seperate nib file. I was trying to follow the applescript studio example "Display Panel"

when I left the
load panel "statusPanel" from nib "statusPanel"

in, I got a NSReceiverEvaluationScriptError: 4 (1)

What is the advantage / disadvantage of having more than one nib file?

Thanks so muc for your help.

Jun 29, 2006 10:58 AM in response to Michael Ewald

Thanks for the response,

right now the window is in a seperate nib file. I was
trying to follow the applescript studio example
"Display Panel"


Then you need to load it, look at the example, you see panelWIndow is declared as property:

property panelWIndow : missing value

then inside on click handler:

if panelWIndow is equal to missing value then
load nib "statusPanel" -- if your nib is statusPanel.nib
set panelWIndow to window "statusPanel" --> that's AppleScript window name
end if

then you can use:

display panel panelWIndow attached to window "main"

What is the advantage / disadvantage of having more
than one nib file?


Not a whole lot in simple app, because you have to load it to use it.
But in more complex apps, the advantage is that you don't commit run time memory, if the users don't use it.

AppleScript Studio: status bar and panel window

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple ID.