Detecting scroll to bottom of alert text
Detecting scroll to bottom of alert text
- Subject: Detecting scroll to bottom of alert text
- From: DEAN MARSHALL via AppleScript-Users <email@hidden>
- Date: Fri, 3 Apr 2020 10:02:09 -0400
Hey all. Hope your staying virus free in this insanity!
I’m hoping someone can offer advice on how to detect a scroll to the bottom or
even a scroll on this alert text I modified. Developer Documentation points
towards scrollViewDidEndDecelerating but my attempts to use it or detect a
scroll didn't work.
Thank you for any advice!
- Dean
—beginning of script
-- Modified Script originally created by the amazing Takaaki Naganoya
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
property |NSURL| : a reference to current application's |NSURL|
property NSFont : a reference to current application's NSFont
property NSView : a reference to current application's NSView
property NSAlert : a reference to current application's NSAlert
property NSColor : a reference to current application's NSColor
property NSTextView : a reference to current application's NSTextView
property NSScrollView : a reference to current application's NSScrollView
property NSRunningApplication : a reference to current application's
NSRunningApplication
property returnCode : 0
set mainMsg to "This is the mainMsg"
set subMsg to "This is the SubMsg"
set bodyMsg to "This is a long paragraph that has lots of gibberish and even
more gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish. This is a long paragraph that has lots of
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish. This is a long
paragraph that has lots of gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish. This is a long paragraph that has lots of gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish and even more gibberish and even more
gibberish and even more gibberish"
set paramObj to {myMessage:mainMsg, mySubMessage:subMsg, myBodyMsg:(bodyMsg),
mesWidth:400, mesHeight:200, fontName:"Times New Roman", fontSize:12.0}
my dispTextViewWithAlertdialog:paramObj --for debug
my performSelectorOnMainThread:"dispTextScrollingWithAlertdialog:"
withObject:paramObj waitUntilDone:true
on dispTextViewWithAlertdialog:paramObj
--Receive Parameters
set aMainMes to (myMessage of paramObj) as string --Main Message
set aSubMes to (mySubMessage of paramObj) as string --Sub Message
set mesStr to (myBodyMsg of paramObj) as string --Long Text Field
set aWidth to (mesWidth of paramObj) as integer --TextView width
set aHeight to (mesHeight of paramObj) as integer --TextView height
set aFontName to (fontName of paramObj) as string --TextView font name
set aFontSize to (fontSize of paramObj) as real --TextView font size
-- Create a TextView with Scroll View
set aScroll to NSScrollView's alloc()'s initWithFrame:(current application's
NSMakeRect(0, 0, aWidth, aHeight))
set aView to NSTextView's alloc()'s initWithFrame:(current application's
NSMakeRect(0, 0, aWidth, aHeight))
aView's setRichText:true
aView's useAllLigatures:true
aView's setFont:(NSFont's fontWithName:aFontName |size|:aFontSize)
aView's setString:mesStr
aScroll's setDocumentView:aView
aView's enclosingScrollView()'s setHasVerticalScroller:true
(aScroll's setDelegate:me)
---(aScroll's setTarget:me)
(aScroll's setAction:"setMethod:")
set theAlert to NSAlert's alloc()'s init()
tell theAlert
--for Messages
its setMessageText:(aMainMes)
its setInformativeText:(aSubMes)
--for Buttons
set agreeButton to its addButtonWithTitle:"Agree"
its addButtonWithTitle:"Disagree"
--Add Accessory View
its setAccessoryView:(aScroll)
---when I can figure out how to detect scroll to bottom use this
tell agreeButton to setEnabled:false
set myWindow to its |window|
end tell
-- show alert in modal loop
NSRunningApplication's currentApplication()'s activateWithOptions:0
my performSelectorOnMainThread:"doModal:" withObject:(theAlert)
waitUntilDone:true
if (my returnCode as number) = 1001 then error number -128
end dispTextViewWithAlertdialog:
on doModal:aParam
set (my returnCode) to aParam's runModal()
end doModal:
----havent gotten this far to even know if it works
on setMethod:sender
set theWindow to sender's |window|()
set theAlert to current application's NSAlert's alloc()'s init()
my (agreeButton's setEnabled:true)
end setMethod:
--end of script
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden