• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Is this possible?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Is this possible?


  • Subject: Re: Is this possible?
  • From: email@hidden
  • Date: Sat, 29 Aug 2015 11:20:02 -0400

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

  • Follow-Ups:
    • How to specify cocoa bindings options?
      • From: email@hidden
References: 
 >Re: Is this possible? (From: Shane Stanley <email@hidden>)

  • Prev by Date: Re: Is this possible?
  • Next by Date: How to specify cocoa bindings options?
  • Previous by thread: Re: Is this possible?
  • Next by thread: How to specify cocoa bindings options?
  • Index(es):
    • Date
    • Thread