Scrollable Wrapping Text in DIalog?

My original post asked about how I could generate a dialog with lengthy scrollable text which wraps and only allow “Agree” button to be pressed when reaching the bottom of scroll similar to a EULA agreement?

I answered most of my own question by checking out Takaaki Naganoya’s TexView script on piyocast.com. He had all kinds of cool extras in it as a bonus.

enclosingScrollView()’s setHasVerticalScroller:true was the simple answer to the first portion.

I cannot figure out how to detect when scrolling or scrolled to bottom of text to enable Agree Button. Developer Documentation points towards scrollViewDidEndDecelerating but my attempts to use it or detect a scroll didn’t work.

Thanks!

My current script is:


-- 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:


I guess you are making a kind of EULA (End-Users License Agreement) dialog with it.

AppleScriptObjC code on Script Editor has poor ability to catch various notifications.
I guess you want to control “OK” button enable/disable next.

If you take many struggles and time, it may be available.

I’ll suggest you to make it on Xcode. Xcode-based AppleScript app can receive various notifications you want. And it can contain sdef file to control from other AppleScripts.