A Question about NsStepper

Hello,

I’ve had a lot of trouble finding much information on scripting the NsStepper object with AppleScript Studio. I’ve come up with some code that does the job, but only the ‘up’ arrow will work (the down arrow works, but it only makes my numbers go ‘up’). I’ve disabled the NsTextField from being accessed except through the NsStepper, and I have a checkbox that will disable the NsStepper itself if checked. Here is the code:


global theMinute
set theMinute to 0
set state of button "theCheck" to 0

on clicked theObject
	if name of theObject is "theCheck" then
		if state of button "theCheck" of theObject's super view = 1 then
			set theMinute to "*"
			set contents of text field "theCounter" of theObject's super view to ""
		else if state of button "theCheck" of theObject's super view = 0 then
			set theMinute to 5
			set contents of text field "theCounter" of theObject's super view to 5
		end if
	else if name of theObject is "theCounter" then
		if state of button "theCheck" of theObject's super view = 0 then
			set theMinute to (contents of text field "theCounter" of theObject's super view) as integer
			set theStepperValue to (contents of stepper "theCounter" of theObject's super view) as integer
			set contents of text field "theCounter" of theObject's super view to theMinute + 1
			if theMinute = 59 then
				set theMinute to 0
				set contents of text field "theCounter" of theObject's super view to theMinute
			end if
		end if
	end if
end clicked

Any help or a pointer in the right direction would be appreciated!

DOAH!

I got it. I’m just making this way to hard. Here’s the code as I hope it helps someone else:


global theMinute
set theMinute to 0
set state of button "theCheck" to 0

on clicked theObject
	if name of theObject is "theCheck" then
		if state of button "theCheck" of theObject's super view = 1 then
			set theMinute to "*"
			set contents of text field "theCounter" of theObject's super view to ""
		else if state of button "theCheck" of theObject's super view = 0 then
			set theMinute to 5
			set contents of text field "theCounter" of theObject's super view to 5
		end if
	else if name of theObject is "theCounter" then
		if state of button "theCheck" of theObject's super view = 0 then
			set theMinute to (contents of text field "theCounter" of theObject's super view) as integer
			set theStepperValue to (contents of stepper "theCounter" of theObject's super view) as integer
			set contents of text field "theCounter" of theObject's super view to contents of stepper "theCounter" of theObject's super view
		end if
	end if
end clicked

Turns out I don’t need to be assigning numbers to the NsStepper–it does it automatically.