Signals & slots in Juce


#21

I have forgotten why I posted my original post (see post 2 in this thread), and now I don’t understand what your file does @jwezorek lol


#22

lol … yeah that happens. basically dont look at the implemenation, look at the usage. All of this is about doing what Qt does regarding the way it hooks a button click to a button click handler but without using code generation and without using a super heavy-weight mountain of C++ like boost::signals. The code I posted is a little confusing but it is (1) short and (2) at the end of the day just a wrapper around a list of std::functions.


#23

I seem to remember wanting to be able to do things like:

button.mouseDown = []() { DBG( "you clicked the button"); };
button.mouseEnter = []() { DBG( "you moused over the button"); };

but that was impossible with juce (hint hint @jules)
so, this whole signal/slot thing came up so we could type:

delegate.connect( &button, Button::mouseDown, []() {DBG( "you clicked the button");} );
delegate.connect( &button, Button::mouseEnter, []() { DBG( "you moused over the button"); } );

which was still better than the whole addListener(this)/buttonClicked(Button*) system when you have a bunch of buttons in your GUI, but not as good as the first one.

somethin’ to consider…