Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Can't read anything in a second window object of the "on will open" handler (Addendum)



By the way, Phil - I do appreciate your detailed explanation. No need to apologize for it. Actually, I learned quite a few things from your post.

Cheers and more power to you all in this forum for your kind assistance.

Romy Opena
 
Romeo T. Opena, PhD
Managing Director/Plant Breeder
ARCH Seed (Thailand) Co., Ltd.
138 Moo 2, Tambon Samrongmai
Lahansai, Buriram
THAILAND 31170
Mobile phone: +66-81-8812374; +66-84-3339260

concurrently also


President and CEO
HORTIGENE-Asia, Inc.
Malaybalay, Bukidnon, Philippines and
Jember, East Java, Indonesia
Mobile phone: +62-81805496684


----- Original Message ----
From: "email@hidden" <email@hidden>
To: email@hidden
Sent: Wednesday, May 14, 2008 2:00:36 AM
Subject: AppleScript-Studio Digest, Vol 5, Issue 96

Send AppleScript-Studio mailing list submissions to
    email@hidden

To subscribe or unsubscribe via the World Wide Web, visit
    http://lists.apple.com/mailman/listinfo/applescript-studio
or, via email, send a message with subject or body 'help' to
    email@hidden

You can reach the person managing the list at
    email@hidden

When replying, please edit your Subject line so it is more specific
than "Re: Contents of AppleScript-Studio digest..."


Today's Topics:

  1. Re: Control the font in a text view (Gil Dawson)
  2. get the properties of a record (Academic Question) (Gil Dawson)
  3. Re: Can't read anything in a second window object of the "on
      will    open" handler (Philip Buckley)
  4. Re: Simple newbie question (Brian Christmas)
  5. Re: Can't read anything in a second window object of the "on
      will    open" handler (Philip Buckley)
  6. Re: Can't read anything in a second window object of the "on
      will    open" handler (Andreas Kiel)


----------------------------------------------------------------------

Message: 1
Date: Mon, 12 May 2008 13:57:58 -0700
From: Gil Dawson <email@hidden>
Subject: Re: Control the font in a text view
To: <email@hidden>
Message-ID: <p0624080cc44e5f526a62@[66.134.166.117]>
Content-Type: text/plain; charset="us-ascii" ; format="flowed"

Yes!  Perfect!  That's it!

Thanks, Philip!

--Gil

At 4:23 P +0100 5/11/08, Philip Buckley wrote:
>As you have discovered, the font you set in Interface Builder
>doesn't stick. You can, however, set the font in your code. You need
>to use a "call method". Add this line to your code:
>
>    set its font to call method "fontWithName:size:" of class
>"NSFont" with parameters {"Courier", 14}
>
>So your code looks like this:
>
>    tell text view 1 of scroll view 1 of window "Lyrics"
>        set its font to call method "fontWithName:size:" of
>class "NSFont" with parameters {"Courier", 14}
>        set its contents to myString
>    end tell
>
>The font and font size that you want for the text view is set in the
>parameters of that line ... {"Courier", 14}. If you wanted a font
>style other than regular, e.g. if you wanted the text in the text
>view displayed in Times Italic, 18 point, then the parameters would
>be ... {"Times-Italic", 18}
>
>Hope that helps
>
>Philip
>
>
>
>  On Sun 11/05/08  6:05 AM , Gil Dawson email@hidden sent:
>>  As my first AS project, I have managed to create a little window with
>>
>>  a few buttons and a text view that displays the contents of myString
>>
>>  when my program executes the following code:
>>
>>
>>
>>  tell text view 1 of scroll view 1 of window "Lyrics"
>>
>>  set its contents to myString
>>
>>  end tell
>>
>>
>>
>>  I would like to display this string in a monospaced font, like Monaco
>>
>>  or Courier, for example.  Any ideas on how to do this?
>>
>>
>>
>>  I tried...
>>
>>
>>
>>  in Interface Builder, I...
>>
>>  selected the Text View
>>
>>  (or the Scroll View; it doesn't seem to make any difference)
>>
>>  pulled down from Format to Font to "Show Fonts"
>>
>>  in the Font floating window that appeared,
>>
>>  selected "Fixed Width" Courier" "Regular" "12"
>>
>>  (Here I wasn't sure what to do so I...)
>>
>>  closed the Font floating window
>>
>>
>>
>>  Then I clicked "Build and Go" and "Save All".  In a few seconds, my
>>
>>  app launched and myString appeared in the window, but still in the
>>
>>  same old proportional font.
>>
>>
>>
>>  Any suggestions?
>>
>>
>>
>>  --Gil
>---- Message sent via KC WebMail - http://webmail.mistral.net/
>  _______________________________________________
>Do not post admin requests to the list. They will be ignored.
>AppleScript-Studio mailing list      (email@hidden)
>Help/Unsubscribe/Update your Subscription:
>http://lists.apple.com/mailman/options/applescript-studio/email@hidden
>
>This email sent to email@hidden



------------------------------

Message: 2
Date: Mon, 12 May 2008 14:49:02 -0700
From: Gil Dawson <email@hidden>
Subject: get the properties of a record (Academic Question)
To: <email@hidden>
Message-ID: <p0624080dc44e6912b370@[66.134.166.117]>
Content-Type: text/plain; charset="us-ascii"

Is there a way within an AppleScript script to get the properties of
an arbitrary record (i.e., one for which you don't know its
properties a priori)?

Both Smile's console and Script Editor's Result window do a fine job
of showing an arbitrary record's properties and values, but I don't
see a way to do the same thing within AppleScript.

e.g.,

  set myRecord to {a:1, b:2} --> result: {a:1, b:2}

Anyone figured it out?

--Gil
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.apple.com/mailman/private/applescript-studio/attachments/20080512/2898fcd6/attachment.html

------------------------------

Message: 3
Date: Mon, 12 May 2008 19:01:51 +0100
From: Philip Buckley <email@hidden>
Subject: Re: Can't read anything in a second window object of the "on
    will    open" handler
To: email@hidden
Message-ID: <email@hidden" href="mailto:email@hidden">email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

There is nothing in your code per se that I can see to cause the 
second "if-end if" block to be accessed.

If I were to debug it, I would do this:

1. take out - temporarily - the "try" and "end try" lines.

At the moment if something is causing an error, you're not to know it 
- the code will just jump to "end will open".

2. put a "log theObject" line in as the first line after "on will open 
theObject"

Run and check the log to see that the handler is being called at all. 
Note that with Xcode 3 you bring up the log window by selecting 
"Console" from the "Run" menu.

If nothing appears in the log when it should (meaning that the handler 
isn't being called), then you need to:

a. check your connection in Interface Builder. One thing I have 
noticed with the new Interface Builder is that when you click 
somewhere in an open window the Inspector palette shows the content 
view of the window, not the window. Check the title in the Inspector 
Palette. It should say "Window ..." not "View ...". If you're seeing 
"View ...", to get the window you need to click again on the title bar 
of your window.

b. If the connection is all OK, then the problem might well be 
occurring BEFORE the "on will open" handler should be called. If there 
is an "on awake from nib" handler, I'd be looking for an error in 
there. I'd also check the code for opening the window (the code that 
should cause the "on will open" handler to be triggered).

If the log says something like "... window id ...", then the handler 
is being called, so ...

3. put a "log objectname" on a line after "set objectname to name of 
theObject as Unicode text"

Run and check the log, you should see "genPrefs". If you do, then I 
can't see any reason why the "if objectname is "genPrefs" then" block 
shouldn't be accessed ... but my guess is that you won't see 
"genPrefs" and there is something problematic happening earlier on.

Apologies if the above is all a case of "stating the obvious"!

Philip





On 11 May 2008, at 23:35, Romy Opena wrote:

>
> Hi All,
>
> After switching to Xcode 3.0, I suddenly had problem with my 
> application that worked with the old version of Xcode.
>
> In my "will open" handler, I have these code snippets:
>
> on will open theObject
> try
> set objectname to name of theObject as Unicode text
> --no problem reading codes in window "main"
> if objectname is"main"then
> tell window"main"
> --codes inside this tell block are read perfectly; no problem
> end tell
> end if
>
> if objectname is "genPrefs" then
> --display dialog "I am inside this if block (this line is not even 
> read at all)
> tell window "genPrefs"
> --it follows that the codes inside this tell block aren't read either
> end tell
> end if
> end try
> end will open
>
> Is there any particular reason why the codes in second "if-end if" 
> block above can't be accessed? Note: The object "genPrefs" is a 
> preference window that contains tab view and tab view items but the 
> most immediate problem obviously is reading the first line (display 
> dialog) in the block. I put that line simply for test.
>
> Would appreciate any lead on the above problem.
>
> Many thanks.
>
> Romy Opena


------------------------------

Message: 4
Date: Tue, 13 May 2008 20:20:59 +1000
From: Brian Christmas <email@hidden>
Subject: Re: Simple newbie question
To: applescript-studio-request <email@hidden>
Message-ID: <email@hidden" href="mailto:email@hidden">email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes

G'day.

I'm not used to a list with no auto reply, so sent this offlist first, 
sorry.

Keep in mind.....

1. Some APPS have a different process name than the name used to open 
them.

eg 'QuarkXPress Passport' needed to open it, but it's process name is 
only 'QuarkXPress'

2. Some APPS don't like the open command, instead use activate, as in 
my script below.


Run this script from the Script editor, replacing with your App names, 
and in the Result window read the process names.

Regards

Santa

tell application "Finder"
    tell application "Adobe Photoshop CS3"
        activate
    end tell
    tell application "QuarkXPress Passport"
        activate
    end tell
end tell

tell application "Finder"
    get every process
end tell


This will be your script once you've got the process name right


set ProcessOne to name_of_your_process
tell application "Finder"
    if ProcessOne is not in (get every process) then
       
        tell application "Adobe Photoshop CS3"
            activate
        end tell
        tell application "QuarkXPress Passport"
            activate
        end tell
       
    else
       
        tell application "Adobe Photoshop CS3"
            quit
        end tell
        tell application "QuarkXPress Passport"
            quit
        end tell
       
    end if
end tell


------------------------------

Message: 5
Date: Tue, 13 May 2008 10:43:59 +0100
From: Philip Buckley <email@hidden>
Subject: Re: Can't read anything in a second window object of the "on
    will    open" handler
To: email@hidden
Message-ID: <email@hidden" href="mailto:email@hidden">email@hidden>
Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes


On 12 May 2008, at 19:01, Philip Buckley wrote:

> There is nothing in your code per se that I can see to cause the 
> second "if-end if" block to be accessed.

I should, of course, have written:

    There is nothing in your code per se that I can see to cause the 
second "if-end if" block NOT to be accessed.

A rather important "not".

    I was really trying to say ... your code looks fine ... if I were to 
try to track the problem down then I would ...

Apologies if I've confused anyone

Philip


------------------------------

Message: 6
Date: Tue, 13 May 2008 16:08:21 +0200
From: Andreas Kiel <email@hidden>
Subject: Re: Can't read anything in a second window object of the "on
    will    open" handler
To: Philip Buckley <email@hidden>
Cc: email@hidden
Message-ID: <email@hidden" href="mailto:email@hidden">email@hidden>
Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed

As Philip suggested in his previous mail you should add a name to any 
of those items then use something like:
on will open theObject
set objName to name of theObject
log {"on will open theObject", objName}
...
end

This way you can track whether theObject is addressed at all. If not, 
then double-check in IB.

Andreas





------------------------------

_______________________________________________
AppleScript-Studio mailing list
email@hidden
http://lists.apple.com/mailman/listinfo/applescript-studio

End of AppleScript-Studio Digest, Vol 5, Issue 96
*************************************************

 _______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.