Wednesday, November 26, 2014

#1 2012-03-05 02:51:03 pm

Domminust
Member
Registered: 2007-04-02
Posts: 32
Website

Couple of questions, Scrollable text window and input from textfield

Hello, I'm getting back into scripting. Right now I have a couple questions that have stumped me and cant seem to find help on google, though its probably out there...

1.) I want to create a scrollable textfield with sliders...

2.) How can I input text from a textfield to a given program, such as input to text edit. Either upon a button or just pressing enter.

I'm creating a game like program for a game, which contains lots of macro's etc.

Thank you for any help!

-Happy scripting smile

Last edited by Domminust (2012-03-05 02:55:13 pm)


- Domminust
\m/ (><) \m/

Offline

 

#2 2012-03-05 04:09:36 pm

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

Re: Couple of questions, Scrollable text window and input from textfield

Domminust wrote:

1.) I want to create a scrollable textfield with sliders...

You need to use an NSTextView, not an NSTextField.

2.) How can I input text from a textfield to a given program, such as input to text edit. Either upon a button or just pressing enter.

You get the text from the text field (or text view), and then use normal scripting to put it into your application.


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

Offline

 

#3 2012-03-06 12:15:03 am

Domminust
Member
Registered: 2007-04-02
Posts: 32
Website

Re: Couple of questions, Scrollable text window and input from textfield

Shane Stanley wrote:

You need to use an NSTextView, not an NSTextField.

Yes I have tried to use NSTextView, however it does not let me edit the text in Xcode, when I double click it to highlight the text field, there is no curser and am not able to type. However I can type there when I launch my program but I want text to be saved there on the application permanently.

You get the text from the text field (or text view), and then use normal scripting to put it into your application.

What would the script be? big_smile

Last edited by Domminust (2012-03-06 12:19:57 am)


- Domminust
\m/ (><) \m/

Offline

 

#4 2012-03-06 12:29:54 am

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

Re: Couple of questions, Scrollable text window and input from textfield

Domminust wrote:

Yes I have tried to use NSTextView, however it does not let me edit the text in Xcode, when I double click it to highlight the text field, there is no curser and am not able to type. However I can type there when I launch my program but I want text to be saved there on the application permanently.

Text views don't work like that. You will have add the text in code at launch, or somewhere else convenient. You can probably just use insertText_.

What would the script be?

That depends on the application in question -- there's no single script that suits all.


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

Offline

 

#5 2012-03-06 12:39:24 am

Domminust
Member
Registered: 2007-04-02
Posts: 32
Website

Re: Couple of questions, Scrollable text window and input from textfield

Shane Stanley wrote:

Text views don't work like that. You will have add the text in code at launch, or somewhere else convenient. You can probably just use insertText_.

Ok, where is this "Code Launch" to add the text.... or how do I use insertText_

That depends on the application in question -- there's no single script that suits all.

Ok.. back in the day I would use a script like this:

tell application "system events"
tell application "textedit"
on mybuttonhandler_(sender)
set mytext to the contents of text field "textfield"
keystroke mytext

So say I want to input text from a text field to some application?


Thanks again for your help, like I said its been a while since I played with scripting since xcode 2.4

Last edited by Domminust (2012-03-06 12:47:29 am)


- Domminust
\m/ (><) \m/

Offline

 

#6 2012-03-06 04:32:54 am

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

Re: Couple of questions, Scrollable text window and input from textfield

Domminust wrote:

Ok, where is this "Code Launch" to add the text....

There'll be an applicationWillFinishLaunching_() handler in the app delegate class; put it in there.

Ok.. back in the day I would use a script like this:

tell application "system events"
tell application "textedit"
on mybuttonhandler_(sender)
set mytext to the contents of text field "textfield"
keystroke mytext

So say I want to input text from a text field to some application?

Thanks again for your help, like I said its been a while since I played with scripting since xcode 2.4

It's all changed somewhat since then; AppleScriptObjC is nothing like AppleScript Studio. Unfortunately there's no official Apple documentation, but you might want to look around here at the various discussions. The short story is that you're going to have to learn some of the basics if you're going to get anywhere with it.


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

Offline

 

#7 2012-03-06 05:02:01 am

Domminust
Member
Registered: 2007-04-02
Posts: 32
Website

Re: Couple of questions, Scrollable text window and input from textfield

*shrug* cocoa-applescript program.. no idea how to open app delegate class.... or you mean connection inspector?

hmm  Thank you for trying to help, I don't want to keep bothering you with my noobyness smile


- Domminust
\m/ (><) \m/

Offline

 

#8 2012-03-06 05:15:30 am

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

Re: Couple of questions, Scrollable text window and input from textfield

So let's start at the top. What version of OS and Xcode are you running?


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

Offline

 

#9 2012-03-06 05:41:50 am

Domminust
Member
Registered: 2007-04-02
Posts: 32
Website

Re: Couple of questions, Scrollable text window and input from textfield

OS : 10.6.8
xcode 4.2

cocoa-applescript application.

Last edited by Domminust (2012-03-06 05:46:15 am)


- Domminust
\m/ (><) \m/

Offline

 

#10 2012-03-06 05:53:51 am

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

Re: Couple of questions, Scrollable text window and input from textfield

OK, the default script that opens is the app delegate class.

You're going to have to look at the tutorials around here or elsewhere on the Web, or stump up for my book, I'm afraid -- it's reasonably complex to get started. It's not the sort of thing that can be answered in one simple post here.


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

Offline

 

Board footer

Powered by FluxBB

[ Generated in 0.023 seconds, 10 queries executed ]

RSS (new topics) RSS (active topics)