# Inconsistent API for change notifications on controls

**URL:** <https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043>\
**Category:** General JUCE discussion\
**Created:** [December 17, 2010, 4:56pm UTC](https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043 "2010-12-17T16:56:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 17, 2010, 4:56pm UTC](https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043/1 "2010-12-17T16:56:54Z")

</div>

Consider the following function signatures:

```auto
void Button::setToggleState (bool shouldBeOn, bool sendChangeNotification);
void ComboBox::setSelectedId (const int newItemId, const bool dontSendChangeMessage)
```

This is pretty self explanatory. true and false have opposite meanings for functions that perform similar operations.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 17, 2010, 5:09pm UTC](https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043/2 "2010-12-17T17:09:19Z")

</div>

That’s something that has been annoying me for a couple of years now!

It’s easy enough to change, but will mean a whole lot of annoyance to existing code. The only safe way to change it is to replace it with an enum or something, so all existing code breaks and people need to go through explicitly replacing the bools with a descriptor. That’d be a much better design, but I’ve been reluctant to do it because it’ll be such a nuisance to do!

---

<div class="post-metadata">

**Author:** ![TheVinn](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thevinn/32/806_2.png) [@TheVinn](https://forum.juce.com/u/TheVinn)\
**Post date:** [December 17, 2010, 5:12pm UTC](https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043/3 "2010-12-17T17:12:21Z")

</div>

You might hate this, but:

```auto
void Button::setToggleStateAndNotify (bool shouldBeOn) { setToggleState (shouldBeOn, true); }
void Button::setToggleStateWithoutNotify (bool shouldBeOn); { setToggleState (shouldBeOn, false); }
```

Of course I could just add this in a subclass without disturbing Juce.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [December 17, 2010, 5:19pm UTC](https://forum.juce.com/t/inconsistent-api-for-change-notifications-on-controls/6043/4 "2010-12-17T17:19:11Z")

</div>

Yes, that’d be another approach. It’s on my to-do-list to have a look at this!
