• 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
Vertical Scrolling- An example that works
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Vertical Scrolling- An example that works


  • Subject: Vertical Scrolling- An example that works
  • From: Richard Covert <email@hidden>
  • Date: Sat, 29 May 2004 21:06:25 -0500

I just got the following form the online XCode documentation.

This is the handler in my code that works by placing the text at the
bottom of the text view and it WORKS!!

The "awake from nib" handler shows how to use my handlers.


on awake from nib theObject
tell StatusField to clearText()
tell StatusField to updateText to "Just Started"
end awake from nib


script StatusField
to updateText to message
tell window "main"
-- copy the contents of text field "statusField" to oldMessage
copy the contents of the text view "statusTextView" of scroll view
"statusScrollView" to oldMessage
copy oldMessage & return & message to newMessage
-- display dialog "updateText: newmessage is " & newMessage
-- set the contents of text field "statusField" to newMessage
copy the newMessage to the contents of the text view
"statusTextView" of scroll view "statusScrollView"
tell text view "statusTextView" of scroll view "statusScrollView" --
of window "main"
set theText to contents
set theLength to (length of theText)
call method "scrollRangeToVisible:" of object it with parameter
{theLength, theLength}
end tell
update
end tell
end updateText

to clearText()
set the contents of the text view "statusTextView" of scroll view
"statusScrollView" of window "main" to ""
end clearText

end script




Although the scroll command is not supported through AppleScript Studio
version 1.3, you can use the call method command to scroll. For a text
view, for example, you can use call method with the
scrollRangeToVisible: method of the NSText class (the text view class
inherits from text, as NSTextView inherits from NSText).

For a simple window main with a text view myText, in a scroll view
scroller, the following statements will scroll to the bottom of the
text view.

tell text view "myText" of scroll view "scroller" of window "main"

set theText to contents

set theLength to (length of theText)

call method "scrollRangeToVisible:" of object it

with parameter {theLength, theLength}

end tell

Substituting the following version of the call method statement would
instead scroll to the top of the view:

call method "scrollRangeToVisible:" of object it with parameter {0,
0}
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.


  • Prev by Date: Re: Setting the Vertical Scroller to the bottom
  • Next by Date: Re: How to select the current person in address book
  • Previous by thread: Re: Setting the Vertical Scroller to the bottom
  • Next by thread: dumb question
  • Index(es):
    • Date
    • Thread