0

I have the following in a bb.cascades QML file:

   Container {
        id: rangeSelector

        bottomPadding: 5
        layout: StackLayout {
            orientation: LayoutOrientation.LeftToRight
        }

        Container {
            Button {        
                id: buttonA            
                text : "1D"
                opacity: 1.0
            }
        }

        Container {
            Button {
                id: buttonB            
                text : "5D"
                opacity: 0.5
            }
        }
    }

How do I change the opacity of buttonA, when buttonB is tapped?

I'm totally new to QML, read some BB10 cascades documentation, but can't find how to hook things like this up.

My goal of this question is to understand how to, in general, change things in other 'objects' on a tap or change inside another. But I do have the above issue (but then with 6 buttons instead of 2; trying to create a kind of SegmentControl with more than 4 segments).

meaning-matters
  • 21,929
  • 10
  • 82
  • 142

1 Answers1

1

It was quite simple:

Container {
    Button {        
        id: buttonA            
        text : "1D"
        opacity: 1.0
        onClicked: {
            buttonA.opacity = 1.0
            buttonB.opacity = 0.5
        }
    }
}

Container {
    Button {
        id: buttonB            
        text : "5D"
        opacity: 0.5
        onClicked: {
            buttonA.opacity = 0.5
            buttonB.opacity = 1.0
        }
    }
}
meaning-matters
  • 21,929
  • 10
  • 82
  • 142
  • Congradulations on finding your own answer. You can mark it as the accepted answer and that will finish the question life cycle. – Richard Jun 28 '14 at 14:31
  • No problem. Nice to see people who keep working their problem even after they post a question. – Richard Jun 28 '14 at 22:05