Setting transactionName in UndoManager when a ComboBox changes

Hi folks,

I’m attempting to integrate ComboBox changes with the JUCE UndoManager, so that the name of the parameter shows up in a list of undoable actions when the user changes the ComboBox, and I’m having trouble discerning user GUI input from other changes. For Sliders, you can use the onDragStart and onDragEnd lambdas to set the name of the transaction in UndoManager, as these are only called when the user is touching the sliders.

Note: I’m using APVTS::ComboBoxAttachment, which automatically starts a new transaction before updating the value, inside the beginParameterChange() function.

But for ComboBoxes, there is nothing like this. You can get changes from ComboBox::Listener, or by inheriting from ComboBox and using its valueChanged() function, but those callbacks are received before beginParameterChange() in the ComboBoxAttachment. The onChange lambda of ComboBox, as well as APVTS::Listener, both get called after beginParameterChange(), but these are also called whenever the parameter changes, so if something else causes the ComboBox to change (like a preset switch), all of the ComboBoxes that change will set the name of the current UndoManager transaction.

Does anyone have a clue as to how I can receive a change from a ComboBox only after the user interacts with it?

Let me know if I need to clarify anything. Any/all ideas on this topic are very much appreciated!


I think I found the answer:

AudioProcessorParameter::Listener::parameterGestureChanged() is only called when the user initiates the change on the GUI.

Changed my ComboBoxes to listen to that, and voila, no more callbacks except when the user makes the change.