Take a look at this updated file:
stepper.rp (67.2 KB)
The “spinnerUp” widget tests if the value of “myCounter” is equal to “1 less than the limit” (e.g., “31”). If true, it increases myCounter by 1 and sets the dynamic panel “up” to “disable”. Else it simply increases myCounter. Likewise, for spinnerDown, if myCounter is equal to “1 more than the limit” (e.g., “2”).
If your number box was a Text Field widget, you could use its Text Changed event to test its own value and disable/enable buttons accordingly.
A few other improvements…
- Any time the spinnerUp is clicked it enables spinnerDown and likewise for clicking spinnerDown.
- The dynamic panels, “up” and “down” have blank OnDrag events. This prevents accidentally selecting the text on the spinnerUp and spinnerDown widgets, which tends to happen when rapidly clicking them, due to moving the mouse/finger/pointer slightly when pressing down, thus triggering a “drag” event in the browser–if there is no handler for dragging the browser assumes you want to select text and/or images on the page.