How do you read the value the value of an NSTextfield? I tried
set the value of test to the contents of the text field "text1" of "Window"
but it keeps erroring?? Where am i going wrong.
How do you read the value the value of an NSTextfield? I tried
set the value of test to the contents of the text field "text1" of "Window"
but it keeps erroring?? Where am i going wrong.
hello Tom35
try this
set test to contents of text field "text1" of window "Window"
enjoy
I have a problem that is similar to Tom35’s post,
I can get the text value of a text field but not from a scroll view. Both objects are in a drawer.
set notes to contents of text field “Date Field” of drawer “Drawer” of window “Main”
– this works
set notes to contents of text field “jobnotes” of scroll view “jobnotes” of drawer “Drawer” of window “Main”
– this gives an error NSReceiverEvaluationScriptError: 4 (1)
and this also gives an error…
set notes to contents of text view “jobnotes” of scroll view “jobnotes” of drawer “Drawer” of window “Main”
Any help is appreciated. -Jeff
In a handler, contrary to what you might expect, the “contents” of the text view returns a reference to the view. To get the actual string of text in the view, you need to get it’s “content”. This worked for me…
set notes to content of text view "jobnotes" of scroll view "jobnotes" of drawer "Drawer" of window "Main"
j
Jobu, thatnks for the help, but I’m still getting the same NSReceiverEvaluationScriptError: 4 (1) error
Could it be that I need to setup the NSScrollview object differently? It was dropped in the view just like the NSTextField (which still works fine). Neither have any eventHandlers checked.
on closed theObject
set notes to contents of text field "jobnotes" of drawer "Drawer" of window "Main"
display dialog notes -- Works Fine
set notes to content of text view "jobnotesX" of scroll view "jobnotesX" of drawer "Drawer" of window "Main" -- gives an error
display dialog notes
end closed
Thanks again, Jeff
Did you make sure to provide an AS name for both the text view AND the enclosing scroll view? Neither are named automatically when you drop them or when you change the name of the other. If you click on the ‘text view’ once, you’ve actually selected the scroll view it’s placed in when it is instantiated. Then, double-clicking on it again will highlight the actual text view. BOTH must be named according to how you’re referencing them in your code.
Other than that, I see no problems with your code. Make sure you’ve named the objects as described above, and that your drawer and window are named properly, as well.
j
Jobu,
That was it! it’s working fine now.
What a great tip, I never thought about double clicking on the scroll view, I bet there are other objects that that would work on also.
Thanks, again, -Jeff
Thanks for the help this solved a problem I was having with my project