selectedSegment

Discussion in 'Mac Programming' started by crul, Jul 29, 2012.

  1. crul, Jul 29, 2012
    Last edited: Jul 29, 2012

    macrumors newbie

    Joined:
    Jul 29, 2012
    #1
    (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:

    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:

    Code:
    0
    0
    ---------
    and the following when the right button is active

    Code:
    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)
     
  2. macrumors member

    Mark FX

    Joined:
    Nov 18, 2011
    #2
    Try this code instead.

    Code:
        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
     
  3. thread starter macrumors newbie

    Joined:
    Jul 29, 2012

Share This Page