How to specify cocoa bindings options?
How to specify cocoa bindings options?
- Subject: How to specify cocoa bindings options?
- From: email@hidden
- Date: Sat, 29 Aug 2015 11:20:55 -0400
Sorry, needed to change title
-----Original Message-----
From: nelsonm12 <email@hidden>
To: sstanley <email@hidden>; applescriptobjc-dev <email@hidden>
Sent: Sat, Aug 29, 2015 9:20 am
Subject: Re: Is this possible?
Hi All,
I'm using Shane Stanley's "Dialog Toolkit" and as an experiment wanted to set up cocoa bindings between a text field and a label. I would like to setup continuous updates from the text field so it would show any keystroke changes but am having some difficulty using the right terminology for it. Assuming you have "DIalog Toolkit" installed, this is the experimental code:
-- start code
use AppleScript version "2.3.1"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property textFieldOutlet : missing value
property labelOutlet : missing value
property boundProperty : "Initial state"
tell script "Dialog Toolkit"
check for main -- make sure we are in foreground when testing
set theLabelStrings to {"Random Text", "Random Text", "Even more randome text"}
set maxLabelWidth to max width for labels theLabelStrings
set controlLeft to maxLabelWidth + 6
set {labelOutlet, theTop, newWidth} to create label " total per queue." left inset 0 bottom (0 + 8) max width 250 aligns "left" without multiline
end tell
labelOutlet's bind:"stringValue" toObject:me withKeyPath:"boundProperty" options:(missing value)
tell script "Dialog Toolkit"
set {textFieldOutlet, textFieldLabel, theTop, fieldLeft} to create side labeled field "the field" placeholder text "Stop ID" left inset 0 bottom (theTop + 8) total width 250 label text "textFieldOutlet" field left controlLeft
end tell
textFieldOutlet's bind:"stringValue" toObject:me withKeyPath:"boundProperty" options:"NSContinuouslyUpdatesValueBindingOption"
tell script "Dialog Toolkit"
set allControls to {labelOutlet, textFieldLabel, textFieldOutlet}
-- controlResults will in the same order as allControls
set {buttonName, suppressedState, controlResults} to display enhanced alert "The main title." message "some other stuff" as informational buttons {"Cancel", "OK"} giving up after 120 acc view width 250 acc view height theTop acc view controls allControls without suppression
log controlResults
set {statusMessage, textFieldLabel, textFieldOutlet} to controlResults
end tell
-- end code
with
textFieldOutlet's bind:"stringValue" toObject:me withKeyPath:"boundProperty" options:(missing value")
it will compile fine but doesn't give the desired keystroke by keystroke update. I have played with
...options:"NSContinuouslyUpdatesValueBindingOption"
...options: current application's NSContinuouslyUpdatesValueBindingOption
...options: current application's NSContinuouslyUpdatesValueBindingOption as boolean
...options: current application's NSContinuouslyUpdatesValueBindingOption as number
...options: current application's NSContinuouslyUpdatesValueBindingOption as real
and other but each gives me different compile failures. What's the right way to add this option?
thanks!
-N
_______________________________________________
Do not post admin requests to the list. They will be ignored.
applescriptobjc-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden