I can only make a guess since you're not providing a complete example,
but I don't see a problem with my code doing what you're describing. The
binding isn't broken, the only problem I can see is that the state gets
reversed because the value is changed twice. To achieve the desired
result you need to override trigger().

** Attachment added: "test.qml"
   
https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1494387/+attachment/4461310/+files/test.qml

** Changed in: ubuntu-ui-toolkit (Ubuntu)
       Status: Confirmed => Incomplete

-- 
You received this bug notification because you are a member of Ubuntu
Touch seeded packages, which is subscribed to ubuntu-ui-toolkit in
Ubuntu.
https://bugs.launchpad.net/bugs/1494387

Title:
  CheckBox needs to track external properties

Status in ubuntu-ui-toolkit package in Ubuntu:
  Incomplete

Bug description:
  Often a CheckBox/Switch is used to show the value of a property
  outside of the CheckBox. For example:

  Switch {
      id: hiddenSwitch
      checked: !header.exposed
      onClicked: header.exposed = !header.exposed
  }

  At first look, this code may seem fine, but clicking the switch will
  trigger checked = !checked, which breaks the binding, so if
  header.exposed updates because of events happening outside of the
  switch, the switch will be out-of-sync.

  Perhaps we need to add some properties to the CheckBox:

  CheckBox {
    property Object bindTarget
    property string bindProperty
  }

  and then the behavior of this:
  Switch {
      id: exposedSwitch
      bindTarget: header
      bindProperty: "exposed"
  }

  can do what we want: the switch shows the value of "exposed", and
  clicking the switch should update the "exposed" value (which in turn
  will update the state of the switch).

  Note that in this case we could not track "!exposed", so if we need
  that, some more complicated solution is needed.

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/ubuntu-ui-toolkit/+bug/1494387/+subscriptions

-- 
Mailing list: https://launchpad.net/~touch-packages
Post to     : touch-packages@lists.launchpad.net
Unsubscribe : https://launchpad.net/~touch-packages
More help   : https://help.launchpad.net/ListHelp

Reply via email to