Saturday, December 16, 2017

#1 2013-04-18 06:25:00 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

I try to make a little tool, but i need 3 Checkboxes to select the options. I cant C or C+ or something else, only a bit in applescript. My Tools i did make it before in applescript and want to use it here too. cause they are to complex.

what i did.
a new project in xcode, a cocoa-applescript application.
did build in MainMenu with 3 checkboxes to select each option.
two buttons to cancel or to start.

my plan is, that the user can select one, two or all three option.
and with the start button the applescripts are start and a message on the screen.

here the code of one check button

-----------
property theLabel1 : missing value -- connect to the label text field
property del1 : missing value -- connect to the label text field

   on Uninstall2_(sender)
        theLabel2's setStringValue_("Your Option")
    end Uninstall2_
---------

what i need is to get into a variable if its on or off. so that i can select for the script and for the message.

maybe i am to stupid, but try it now over two weeks to find a little script or help. but all is only for the cocoa app and not AppDelegate.applescript.

i hope you may help me here smile my last hope !

kind regards
andy

Model: MacBook Pro
AppleScript: 4.6.2
Browser: Safari 536.28.10
Operating System: Mac OS X (10.8)

Offline

 

#2 2013-04-18 11:09:51 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Hi,

first of all, please post AppleScriptObjC questions in the AppleScriptObjC forum

easiest solution: define 3 properties

Applescript:


property checkbox1 : false
property checkbox2 : false
property checkbox3 : false

bind the value (!) of each check box to the appropriate property.
Then just read the properties after the user presses the start button


regards

Stefan

Offline

 

#3 2013-04-19 05:02:27 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Thank you and sorry for my mistake of posting
i did as you advise, but it dos not as i need sad

how can i get the status if its ON or OFF ? Maybe thats the solution.

did try it also with:

if state of button "Checkbox1" of window "Main" is 1 then
        theLabel2's setStringValue_("Your Option")
end if

but this give me an error:
CheckBox/AppDelegate.applescript:13: error: Expected “then”, etc. but found “"”. (-2741)

Offline

 

#4 2013-04-19 05:17:24 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

To bind the value properly do the following:

In Interface Builder select the first check box
Press ⌥⌘7 to show the Bindings Inspector

Click on the disclosure triangle next to Value
In the pop up menu next to Bind to select the App Delegate entry
Click the check box next to Bind to to enable it.
Leave Controller Key empty
type checkbox1 into the Model Key Path field and press return (in the parentheses to the right of Value must appear .checkbox1 at the end)

Do the same thing for the other check boxes (connect to checkbox2 and checkbox3)

then you can simply write

Applescript:

if checkbox1 is true then theLabel2's setStringValue_("Your Option")

PS:

In a AppleScriptObjC environment the syntax state of button "Checkbox1" of window "Main" is invalid

Last edited by StefanK (2013-04-19 05:22:05 am)


regards

Stefan

Offline

 

#5 2013-04-19 05:28:32 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Maybe i am to stupid for this. this shortcut dont work by me.
you mean with the interface builder the graphic window where i design my window and checkbox ?

Offline

 

#6 2013-04-19 05:31:21 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Yes, to show Interface Builder select MainMenu.xib in the side bar

Last edited by StefanK (2013-04-19 05:31:37 am)


regards

Stefan

Offline

 

#7 2013-04-19 05:43:37 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Oh. Into the Binding Inspector i get a warning by the "Model Key Path" (exclamation mark "!")

Offline

 

#8 2013-04-19 05:46:43 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

if the exclamation mark is grey you can ignore it


regards

Stefan

Offline

 

#9 2013-04-19 05:54:58 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

yes, its grey. so i can ignor it.

i write a message into the setStringValue_ when it is select.
when i deselect it, can i clear this ?

Offline

 

#10 2013-04-19 06:13:24 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Then you need a IBAction (a handler connected to the selector of the check box), check the state and set/clear the string value


regards

Stefan

Offline

 

#11 2013-04-19 08:21:03 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

A lot to find about the IBAction, but nothing who can use it on my version of Xcode sad all what i find in google is for older versions. the help menu of xcode are not useful.

Offline

 

#12 2013-04-19 08:27:28 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

in AppleScriptObjC just define a hander

Applescript:

on doSomething_(sender)

the name doSomething will appear in Interface Builder in the Connections Inspector (⌥⌘6) as a Received Action
after selecting the App Delegate blue cube. Connect the selector of the checkbox to the action

The handler gets called when the check box is clicked.
The parameter sender is a reference to the check box

loeschl wrote:

… on my version of Xcode


Where did you get 4.6.3 from? The actual version is 4.6.2

Last edited by StefanK (2013-04-19 08:45:54 am)


regards

Stefan

Offline

 

#13 2013-04-19 09:02:11 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

when i click on the "Checkbox" in the builderi dont have it with the name "Checkbox" in the recieved action. Or should have it with a other name ?

there is:
performClick
print
takedoublevaluefrom
...

Offline

 

#14 2013-04-19 09:08:36 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

either select the check box and control-drag the selector (the Sent action) to the App Delegate blue cube,
or select the blue cube and drag from the circle of the handler name (the Received Action) to the check box


regards

Stefan

Offline

 

#15 2013-04-19 09:17:35 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

http://www.loeschl.com/download/Code.png
i think it looks right.. but something is wrong..

Applescript:

script AppDelegate
   property parent : class "NSObject"
property theLabel1 : missing value -- connect to the label text field
property theLabel2 : missing value -- connect to the label text field
property Checkbox1 : false
-- property Checkbox2 : false
-- property Checkbox3 : false
property Main : false

on Checkbox1_(sender)
theLabel1's setStringValue_("Your Option")

end Checkbox1_

if Checkbox1 is true then theLabel2's setStringValue_("Your Option")
if Checkbox1 is false then theLabel2's setStringValue_(" ")

end script

Offline

 

#16 2013-04-19 09:20:45 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

i can download the script also on my web-server as zip-file.

Offline

 

#17 2013-04-19 09:22:40 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Offline

 

#18 2013-04-19 09:43:01 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

I made a few changes, please consider the naming convention that the names of all methods/handlers and non-class variables begin always with a lowercase letter

CheckBox.zip


regards

Stefan

Offline

 

#19 2013-04-19 10:00:32 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Thank you very much ! So i have the Source where i can work.
Really Thank You !

Wish you a nice weekend smile

Offline

 

#20 2013-04-22 08:04:51 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

Thank you very much !! I could solve it all and it works as i wish. A Great tool for me and the Support.

Oe question ist left. sorry.
When i build the App it work well. But when i look inside the app, i can find the sourcecode of "AppDelegate.scpt" as clear text.  can i decode it, so that nobody else may copy my source code ?

sorry for my stupid question.

Offline

 

#21 2013-04-22 08:16:49 am

StefanK
Member
From:: St. Gallen, Switzerland
Registered: 2006-10-21
Posts: 11482
Website

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

In Xcode > Build Settings > section OSACompile - Build Options set Save as Execute-Only to Yes in the target column


regards

Stefan

Offline

 

#22 2013-04-22 08:48:47 am

loeschl
Member
Registered: 2005-12-16
Posts: 16

Re: Xcode 4.6.3 CheckBox Status (AppDelegate.applescript)

WOW !! Really a big big thank you to you !!! A little thing with a big work smile

Offline

 

Board footer

Powered by FluxBB

RSS (new topics) RSS (active topics)