• Skip to main content
  • Skip to search
  • Skip to footer
Cadence Home
  • This search text may be transcribed, used, stored, or accessed by our third-party service providers per our Cookie Policy and Privacy Policy.

  1. Community Forums
  2. Custom IC SKILL
  3. Make boolean buttons mutually exclusive

Stats

  • Locked Locked
  • Replies 3
  • Subscribers 143
  • Views 9201
  • Members are here 0
This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Make boolean buttons mutually exclusive

MorrisDH
MorrisDH over 3 years ago

Is there a preferred SKILL method for creating a group of boolean buttons that allow only one button to be selected?

  • Cancel
  • MorrisDH
    MorrisDH over 3 years ago

    I think I found the answer - hiCreateRadioField.

    Will give it a try.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • MorrisDH
    MorrisDH over 3 years ago

    hiCreateRadioField works but it wasn't exactly what I need. It appeared that at least one option always had to be selected and I wanted the ability to unselect all.

    Add a callback function to hiCreateBooleanButton instead of using radio field.

    procedure( mutuallyExclusiveBooleans(form selButton)
      let( ()
        case(selButton
          ("Option1"
            if(form~>Options1~>value == t form~>Option2~>value = nil))
          ("Option2"
            if(form~>Option2~>value == t form~>Option1~>value = nil)))
      ) ; let
    ) ; procedure

    The selButton option is text that is passed from the callback to indicate which button was pressed. There may be a better way to tell the function who is calling.

            hiCreateBooleanButton( ?name 'Option1
                                   ?buttonText "Option1"
                                   ?defValue 'nil
                                   ?buttonLocation 'left
                                   ?callback "mutuallyExclusiveBooleans(hiGetCurrentForm() \"Option1\")"
            ) ;Boolean
            hiCreateBooleanButton( ?name 'Option2
                                   ?buttonText "Option2"
                                   ?defValue 'nil
                                   ?buttonLocation 'left
                                   ?callback "mutuallyExclusiveBooleans(hiGetCurrentForm() \"Option2\")"
            ) ;Boolean

    Not sure if this is the best way to go but it works.

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel
  • Andrew Beckett
    Andrew Beckett over 3 years ago in reply to MorrisDH

    You could also use a toggle field:

    toggles=hiCreateToggleField(
      ?name 'toggles ?choices list(list('Option1) list('Option2) list('Option3))
      ?prompt "Choose"
      ?callback list(
        lambda((field scope item value)
          unless(boundp('MyInCallback) && MyInCallback
            let(((MyInCallback t))
              ;printf("CB: %L %L %L %L\n" field scope item value)
              foreach(toggle field->_toggleItems
                unless(eq(toggle item)
                  get(field toggle)->value=nil
                )))))
          )
    )
    hiCreateAppForm(?name 'MyForm ?fields list(toggles))
    hiDisplayForm(MyForm)

    This has a callback (specified as a function object because then you find out which toggle was selected) which loops over all toggles and turns off the one that wasn't just pressed. Note that it has this dynamic variable MyInCallback to determine whether it's already in the callback because otherwise turning them off also triggers the callback again which gets a bit tricky (you'd find that you have to press the item twice to turn it on, which would be a bit strange).

    Regards,

    Andrew

    • Cancel
    • Vote Up 0 Vote Down
    • Cancel

Community Guidelines

The Cadence Design Communities support Cadence users and technologists interacting to exchange ideas, news, technical information, and best practices to solve problems and get the most from Cadence technology. The community is open to everyone, and to provide the most value, we require participants to follow our Community Guidelines that facilitate a quality exchange of ideas and information. By accessing, contributing, using or downloading any materials from the site, you agree to be bound by the full Community Guidelines.

© 2025 Cadence Design Systems, Inc. All Rights Reserved.

  • Terms of Use
  • Privacy
  • Cookie Policy
  • US Trademarks
  • Do Not Sell or Share My Personal Information