I have been trying all day to program a stepper. The stepper is connected to a text field. When the stepper is clicked, it changes the value of the text field properly. The thing that seems impossible is that the stepper doesn’t seem to trigger the clicked event or any other event where I put any script. I have tried
On clicked, On action, On Mouse Down and about everything else and NOTHING seems to fire, no matter what check boxes I have marked in interface builder. I even tried the linked text field with On Change, but that doesn’t seem to fire when value changes from the stepper.
Simply, I want to fire a calculation event whenever the user clicks on the stepper. Seems simple :rolleyes: or so it seems.
As a newbie in AppleScript Studio, I appreciate the simple hierarchies and forgiving syntax of good ole HyperCard all the more.
I feel as if I have descended into stepper hell. Any pointers would be appreciated.
Steppers are one of the easiest things to script. You’re doing something wrong there.
Edited: what you should do is start with a stepper. See what happens (maybe logging some info). After knowing what is happenning, use it. You don’t need anybody’s help for this.
I have just added one to my project. It’s really easy. Read the documentation in xCode for help on making it.
A stepper has value, and its invsible. In order to ‘use’ the value, you have to synchronize it with a display field or text field on your window. I justed use an entirely new script in my project to handle my one stepper. If you needed to use multiple steppers or add the stepper into just one script, you’d have to add, after on clicked theobject… if name of theobject is “mystepper” then do whatever. The on clicked is stepper part, and the on action is the script connected to the text box, so when the user modifies the value in the box, the number is transmitted to the steppers (invisible) value and keeps them in sync.
on clicked theObject
tell window "main"
set theValue to (contents of stepper "mystepper") as integer
set contents of text field "mysteppervalue" to theValue
end tell
end clicked
on action theObject
set textValue to contents of theObject
tell window "main"
set contents of stepper "mystepper" to textValue
end tell
end action
SuperMacGuy, you don’t have to use code to keep a text field and stepper in sync; You can use connections in Interface Builders. Here’s an example of connecting a window to a menu item: ib_window_connection.mov
Using that same method, connect the stepper to the takeIntValueFrom: action in the text field, and connect the text field to the takeStringValueFrom: action in the stepper.
I finally got it. It seems there was an empty clicked event and “on click” that intercepted the handler before it got to the mouse down. Anyway, unclicking the “on click” in interface builder seemed to do the trick. The more I work with AppleScript Studio the more I like it, though sometimes it feels like wading through the thick, gunky, mud to go a short distance. XCode has lots of controls and settings and knowing what to do for debugging seems unintuitive. It is somewhat like the old variable and message watcher in HyperCard, but is there a way to watch execution step by step? I see the breakpoints, but it would be nice to be able to see what is happening line by line. The error messages are anything but intuitive very often and it is difficult to know exactly what is generating them and where.
Thanks Bruce, I was just going by the examples in the documentation but I am still working with xCode 1.5 (ugh, blame my IT dept). I’ll check out that tip. Thanks!