PDA

View Full Version : selectedSegment




crul
Jul 29, 2012, 04:06 AM
(using xcode/applescript)
I have a window with a segmented control (with 2 buttons) and a push button. The push button is linked to this code:

property segment : missing value

on buttonPressed_(sender)
log selectedSegment of segment

if (selectedSegment of segment) = 1 then
log "1"
else
log "0"
end if

log "---------"
end buttonPressed_

My problem is with the if statement. My log shows the following when the left button of the segmented control is active:

0
0
---------

and the following when the right button is active

1
0
---------

So it seems that 'log selectedSegment of segment' is returning the right value while the if statement doesn't work. Any idea what I'm doing wrong?

(I'm very new to xcode/applescript and just use it for some personal scripts, so please excuse me if this question is really nubish :p)



Mark FX
Jul 29, 2012, 12:53 PM
Try this code instead.


on buttonPressed_(sender)
log segment's selectedSegment()
if (segment's selectedSegment()) = 1 then
log "selectedSegment = 1"
else
log "selectedSegment = 0"
end if
end buttonPressed_


Regards Mark

crul
Jul 31, 2012, 11:10 AM
Works like a charm, thanks!