Wednesday, December 13, 2017

#1 2009-10-20 07:24:31 pm

Catalyst320
Member
Registered: 2009-09-24
Posts: 38

I love Apple, but they messed up big...

I love Apple.  I have had only Apple computers since I was little, and many of their upgrades have taken some getting used to... like, when iMovie changed in the version after iMovie HD.  But all of the change have been somehow understadable..  All of their changes except for their newest one.  They messed up Applescript Studio.  They did not just change it, and make the interface different, they flat out removed it from Xcode 3.2 .  Now it is some Obj-C/Applescript crap.  I don't want to learn a new language to program in, I want to do the same thing I used to do, which was copy and paste a huge chunk from applescript to XCode... what the hell?

Offline

 

#2 2009-10-20 09:57:00 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

Catalyst320 wrote:

II want to do the same thing I used to do, which was copy and paste a huge chunk from applescript to XCode


Believe it or not, that's what many of us are doing. The code that drives other apps is virtually unchanged; it's only the interface code that's different.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#3 2009-10-21 01:02:20 pm

Catalyst320
Member
Registered: 2009-09-24
Posts: 38

Re: I love Apple, but they messed up big...

Ok fine.  You can still copy/paste applescript code... but the interface code (I guess that is what I was referring to) is very different.  How the heck does it work?

Offline

 

#4 2009-10-21 02:49:55 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: I love Apple, but they messed up big...

A month ago I didn't know what the underscore meant now I've created these:
http://files.me.com/imadrichard/v9b3la -app
http://files.me.com/imadrichard/ppaiha -project (zipped 2.9 MB, 5 MB when unzipped)

I was in the same position but trusted Apple like everyone always should, Apple was right to do what they did. There are simple basics to learn and it's almost no different.

Offline

 

#5 2009-10-21 06:13:12 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

Catalyst320 wrote:

How the heck does it work?


Very well. The lack of documentation is a problem, but you'll find quite a few example projects mentioned around here -- check them out.

Some things are simpler than ASStudio, some are harder, and many are only possible with ASObjC.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#6 2009-10-25 06:59:07 pm

Catalyst320
Member
Registered: 2009-09-24
Posts: 38

Re: I love Apple, but they messed up big...

ok, I'll take ur word for it, i hope ur right, and ASOBJC is easy to learn...  It's ok if u can't/don't want to, but can u direct me to a good (group or one) example project that is easy, and demonstrates a lot of the concepts, bcuz if u learned yourself, you will know where a good place to begin is

Offline

 

#7 2009-10-26 02:04:56 am

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

Catalyst320 wrote:

but can u direct me to a good (group or one) example project that is easy, and demonstrates a lot of the concepts


A lot of good stuff has been posted around here. There's a sample project and explanatory movie at <http://www.macosxautomation.com/applescript/develop/>. Further example projects and details have been posted at <http://www.scriptingmatters.com/ASObjC>, <http://allancraig.net/blog/> and <http://www.tidbits.com/matt/>.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#8 2009-10-29 06:42:40 pm

Catalyst320
Member
Registered: 2009-09-24
Posts: 38

Re: I love Apple, but they messed up big...

Ok.  Simple project.  To learn how the language works, I tried to make a very VERY simple program (that would have been a joke in AS).  I tried to make a program that has a button and two textfields.  The user can fill one of the fields, and then he/she pushes the button.  The text from textfield1 (input by the user) is then copied into textfield2.

Offline

 

#9 2009-10-29 07:16:48 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

So what code have you written so far?


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#10 2009-10-30 01:08:13 pm

Catalyst320
Member
Registered: 2009-09-24
Posts: 38

Re: I love Apple, but they messed up big...

well, everytime I write new code, it never seems to have the same result...  Well, I can like, have a button that, when clicked, displays a dialog with a string literal in it.. Not a variable...

Offline

 

#11 2009-10-30 03:14:48 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: I love Apple, but they messed up big...

Perhaps the code at the bottom of http://macscripter.net/viewtopic.php?id=30898 would help, a little multiplier, with more variables, more interface but nothing in the code more than you should already know from writing dialogs.

Offline

 

#12 2009-10-31 08:56:33 am

pppfff
Member
From:: Freiburg, Germany
Registered: 2009-10-31
Posts: 22

Re: I love Apple, but they messed up big...

First, Thank you for giving all such good advice and examples!

I am new in Apple (4  month) , Applescript (2 month) and have started with Xcode after SnowLeopard.
Have bought the book Applescript Studio Programming for absolute beginners and found that it is worthless now :-(


Shane mentioned the link to www.macosxautomation.com/applescript/develop , this was the link I have found as well and after that I was able to create my first working application some days ago.

I am struggling that there is no documentation, Have found the same method Richard mentioned in one of his posts (The tutorial) , to check the XCode help and then translate.
That was working after a lot of try and errors with the rotate text function = setFrameRotation  (see code below)
but it is not working with the color setting and the position setting of text boxes.
The only thing which is working 50% is the setFrameOrigin_  ,but here my hope is to use x,y parameters, but I have not found a solution.

Is there really no documentation for ASOC ?
Do you have examples for Changing the color of Text, button, windows, moving the text boxes, buttons ?

best regards
pppfff

script RotateTestAppDelegate
   
    property parent : class "NSObject"
    property NSImage : class "NSImage" of current application
       
    property textField : missing value
    property ButtonPlus : missing value
    property ButtonMinus : missing value
    property ButtonTextEffect : missing value
   
   
    property Angle : 90.0
    property Inc : 10.0
       
    on applicationWillFinishLaunching_(aNotification)
       
        tell textField to setFrameRotation_(90.0)
       
    end applicationWillFinishLaunching_
   
    on applicationShouldTerminate_(sender)
        -- Insert code here to do any housekeeping before your application quits
        return true
    end applicationShouldTerminate_
   
    on ViewTextPlus_(sender)
       
        set Angle to Angle + Inc
       
        tell textField to setFrameRotation_(Angle)
        tell textField to setStringValue_(("Plus") as string)
    end ViewTextPlus_
   
   
    on ViewTextMinus_(sender)
       
        set Angle to Angle - Inc
       
        tell textField to setFrameRotation_(Angle)
        tell textField to setStringValue_(("Minus") as string)
    end ViewTextMinus_
   
    on ViewTextEffect_(sender)
       
       
        --tell textField to setFrameOrigin_(100)
              -- working: But what Parameters do I need to place it not only in the left down corner
       

        --tell textField to setBackgroundColor_(RedColor) -- not working

        tell textField to setStringValue_(("Effect") as string)
       
       
    end ViewTextEffect_
   
   
end script


Filed under: asoc

Offline

 

#13 2009-10-31 10:31:13 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

pppfff wrote:

The only thing which is working 50% is the setFrameOrigin_  ,but here my hope is to use x,y parameters, but I have not found a solution.


The frame coordinates are based on the coordinates of the containing view, with the bottom left being {0,0}. The Y value refers to the bottom of the view. So to put a text field in the bottom left of its window:

Applescript:

       tell textField to setFrameOrigin_({0, 0})

To put it top right, you'd do something like this:

Applescript:

       -- get window's frame
       set theFrame to textField's |window|()'s frame()
       -- allow for title bar
       set theFrame to textField's |window|()'s contentRectForFrameRect_(theFrame)
       set {{x:x1, y:y1}, {width:theWidth, height:theHeight}} to theFrame as list
       -- get textField's frame
       set theFrame to textField's frame()
       set {{x:x1, y:y1}, {width:theWidth2, height:theHeight2}} to theFrame as list
       -- move textField to top right
       tell textField to setFrameOrigin_({theWidth - theWidth2, theHeight - theHeight2})

Is there really no documentation for ASOC ?


Apart from the release notes, at this stage no.

Do you have examples for Changing the color of Text, button, windows, moving the text boxes, buttons ?


Moving is done by setFrameOrigin_. You can set the color like this:

Applescript:

       set redColor to current application's class "NSColor"'s redColor() -- case matters; no cap R
       set otherColor to current application's class "NSColor"'s colorWithCalibratedRed_green_blue_alpha_(0, 1, 0, 1)
       tell textField to setBackgroundColor_(redColor)
       tell textField to setTextColor_(otherColor)
       tell mainWindow to setBackgroundColor_(redColor)


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#14 2009-11-01 06:50:31 am

pppfff
Member
From:: Freiburg, Germany
Registered: 2009-10-31
Posts: 22

Re: I love Apple, but they messed up big...

Thank you very much Shane !

All is working now ... except the color Red! smile
First the color change was not working at all, but good that you mentioned the caps is important.
My xcode has changes the  redColor()  to RedColor() automatically and after I tried blue all was ok.
No idea why this happen on my Mac.

With your examples it was even possible for me to change the size of the text box with the command:

tell textField to setFrameSize_({400, 50})

Now I am puzzeling how to find query other sizes like Text Box size.
Have tried with : set theTextboxSize to textField's |FrameSize|()'s frame()

but no luck.

thank you again!
pppfff


Filed under: asoc

Offline

 

#15 2009-11-01 12:09:43 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: I love Apple, but they messed up big...

pppfff wrote:

Thank you very much Shane !

All is working now ... except the color Red! smile
First the color change was not working at all, but good that you mentioned the caps is important.
My xcode has changes the  redColor()  to RedColor() automatically and after I tried blue all was ok.
No idea why this happen on my Mac.


This has to do with how the compiler saves variable names in AppleScript. Once you compile using one variable name,
all future names will be capitalized the same. Really irritating. I believe the reason it is done this way
is so once you have one variable name, you can type the next one in all lowercase and it will reformat it letting
you know that you spelled it correctly.

The way around this is to remove all instances of the specified name from the file. Save and close the
project. When you open it back up, insert the correct name and compile.

Cheers,

Craig

Offline

 

#16 2009-11-01 04:52:50 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

pppfff wrote:

Now I am puzzeling how to find query other sizes like Text Box size.
Have tried with : set theTextboxSize to textField's |FrameSize|()'s frame()

but no luck.


See above:

Applescript:

       set theFrame to textField's frame()


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#17 2009-11-01 04:54:00 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

Craig Williams wrote:

The way around this is to remove all instances of the specified name from the file. Save and close the project. When you open it back up, insert the correct name and compile.


Or if you can't be bothered, surround the name in pipes:

Applescript:

|redColor|


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#18 2009-11-01 05:21:18 pm

Craig Williams
Administrator
From:: Ft. Smith, AR
Registered: 2006-12-07
Posts: 888

Re: I love Apple, but they messed up big...

Shane Stanley wrote:

Or if you can't be bothered, surround the name in pipes:

Applescript:

|redColor|


Sweet! Had not thought of that!

Offline

 

#19 2009-11-01 07:23:56 pm

pppfff
Member
From:: Freiburg, Germany
Registered: 2009-10-31
Posts: 22

Re: I love Apple, but they messed up big...

Shane,
I understand :-)

Being able to read can be an advantage!

Now I see the dimension of the text box. In the example below, I get two times the same results, even the size has been changed.
Is there a kind of update command I have to use?

best regards
pppfff


tell textField to setFrameSize_({200, 100})
       
        set {{x:x1, y:y1}, {width:theWidth2, height:theHeight2}} to theFrame as list
        display dialog theWidth2
        display dialog theHeight2
       
        delay 2
       
        tell textField to setFrameSize_({400, 100})
       
       
        set {{x:x1, y:y1}, {width:theWidth2, height:theHeight2}} to theFrame as list
        display dialog theWidth2
        display dialog theHeight2


PS: Thank you Craig for the hint with the pipe symbols !
      Do not need to buy a puzzle game, have it all here :-)

Offline

 

#20 2009-11-01 07:54:55 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

You haven't updated the value of theFrame -- you need a " set theFrame to textField's frame()" after you change it.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#21 2009-11-03 12:56:11 pm

pppfff
Member
From:: Freiburg, Germany
Registered: 2009-10-31
Posts: 22

Re: I love Apple, but they messed up big...

Shane,

thank you again. It is working !  :-)

Have added it before the "set {{x:x1 ..." line

  tell textField to setFrameSize_({200, 100})
  set theFrame to textField's frame()
  set {{x:x1, y:y1}, {width:theWidth2, height:theHeight2}} to theFrame as list
       
Step by step I am learning, baby steps !

Is it ok to ask another question (or more ;-) ?

How can make the text field scrolling, if the content is too long ?
Or how can I make the font smaller if it is too long ?

best regards
pppfff

Last edited by pppfff (2009-11-03 01:26:43 pm)

Offline

 

#22 2009-11-03 04:21:01 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: I love Apple, but they messed up big...

I would consider a text view.

Offline

 

#23 2009-11-03 04:52:15 pm

Shane Stanley
Member
From:: Australia
Registered: 2002-12-07
Posts: 5199

Re: I love Apple, but they messed up big...

As Richard said, you want an NSTextView rather than an NSTextField.


Shane Stanley <sstanley@myriad-com.com.au>
www.macosxautomation.com/applescript/apps/

Offline

 

#24 2009-11-03 06:04:15 pm

pppfff
Member
From:: Freiburg, Germany
Registered: 2009-10-31
Posts: 22

Re: I love Apple, but they messed up big...

hmmh, two answers an I still have difficulties to find the right object. Sorry!
In the Library I am finding only TextView which is "NSTextView in an NSScrollView", but it is not working for me.

Is there something I am overlooking ?

thank you
pppfff

Offline

 

#25 2009-11-03 06:17:59 pm

Richard
Member
From:: Herefordshire, UK
Registered: 2009-09-09
Posts: 529
Website

Re: I love Apple, but they messed up big...

Make sure you IB link goes to the top of the text view, there will be a thinner separate box at the top, this is the actual text view, the rest is a scroll view.

And as in my tutorial and other examples, the 2 key methods are |string|() and setString() rather than stringValue() and setStringValue()

Last edited by Richard (2009-11-03 06:20:17 pm)

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)