6 Replies Latest reply: Jun 29, 2006 12:34 PM by Michael Ewald
Michael Ewald Level 1 Level 1 (20 points)
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)
  • 1. Re: AppleScript Studio: status bar and panel window
    Cyclosaurus Level 6 Level 6 (12,915 points)
    Question: why do you have a panel?

    You could have a progress indicator in window "main", and just use show/hide command.
  • 2. Re: AppleScript Studio: status bar and panel window
    Michael Ewald Level 1 Level 1 (20 points)
    I'm trying to learn how to use panel's and things like that. Other than that I'm not really sure.

    I think I will stick with show and hide, I was just hoping there was a way to do the panel.
  • 3. Re: AppleScript Studio: status bar and panel window
    Cyclosaurus Level 6 Level 6 (12,915 points)
    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"
  • 4. Re: AppleScript Studio: status bar and panel window
    Michael Ewald Level 1 Level 1 (20 points)
    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.
  • 5. Re: AppleScript Studio: status bar and panel window
    Cyclosaurus Level 6 Level 6 (12,915 points)
    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.
  • 6. Re: AppleScript Studio: status bar and panel window
    Michael Ewald Level 1 Level 1 (20 points)
    hmm, still doesn't work. I'm gonna stick with the show / hide method and test it out on another project.

    Thanks for your help Cyclosaurus!