# Add callbacks for components

**URL:** <https://forum.juce.com/t/add-callbacks-for-components/17808>\
**Category:** General JUCE discussion\
**Created:** [May 23, 2016, 7:46pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808 "2016-05-23T19:46:54Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![akper](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@akper](https://forum.juce.com/u/akper)\
**Post date:** [May 23, 2016, 7:46pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/1 "2016-05-23T19:46:54Z")

</div>

Hi Jules, I’ve used your library, I liked it very much. But there are **drawbacks** , such as for me it would be easier to add **callbacks** than anything in the function. It would be nice if you added it. Sorry for my english, I do not know much of it.

---

<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:** [May 24, 2016, 7:28am UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/2 "2016-05-24T07:28:56Z")

</div>

Sorry, really not sure what you’re asking there!

Do you mean lambdas? If so we’re certainly keen to add more use of them, it’s something we’ll be doing more of this year.

---

<div class="post-metadata">

**Author:** ![akper](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@akper](https://forum.juce.com/u/akper)\
**Post date:** [May 24, 2016, 10:40am UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/3 "2016-05-24T10:40:59Z")

</div>

Yes it is, I mean,  
Here is an example:

> void click(Button \*b){}  
> button-\>onClick = click;

It very comfortable.

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [May 24, 2016, 1:45pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/4 "2016-05-24T13:45:02Z")

</div>

You can of course already implement your own lambda/std::function based callbacks system on top of the existing components…

Still, it would be preferable if Juce itself started adopting that kind of stuff. 😋

---

<div class="post-metadata">

**Author:** ![akper](https://avatars.discourse-cdn.com/v4/letter/a/ccd318/32.png) [@akper](https://forum.juce.com/u/akper)\
**Post date:** [May 24, 2016, 8:49pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/5 "2016-05-24T20:49:20Z")

</div>

Need to try. I think it would be better if it was in JUCE.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [May 24, 2016, 10:47pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/6 "2016-05-24T22:47:52Z")

</div>

a couple different style of Signal/Slot systems have been presented by the forum community: [Signals & slots in Juce](https://forum.juce.com/t/signals-slots-in-juce/15267)

Take a look at this thread.

---

<div class="post-metadata">

**Author:** ![SonicZentropy](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/soniczentropy/32/665_2.png) [@SonicZentropy](https://forum.juce.com/u/SonicZentropy)\
**Post date:** [May 24, 2016, 11:00pm UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/7 "2016-05-24T23:00:10Z")

</div>

I JUST did this exact thing last night and it works really well with JUCE components. I’m not done yet, but all the components I’ve added std::func/lambdas to so far have been structured to where it’s really easy to do aside from having to move a bunch of the base components’ stuff from private to protected.

---

<div class="post-metadata">

**Author:** ![matkatmusic](https://avatars.discourse-cdn.com/v4/letter/m/dfb087/32.png) [@matkatmusic](https://forum.juce.com/u/matkatmusic)\
**Post date:** [November 12, 2017, 9:36am UTC](https://forum.juce.com/t/add-callbacks-for-components/17808/8 "2017-11-12T09:36:30Z")

</div>

@SonicZentropy  
Can you delve a bit deeper and explain what you mean for how you got juce::Components to accept lambdas/std::function\<\>'s as replacements for mouseDown/Move/Over/Exit/Enter/etc…
