Loading...
Searching...
No Matches
juce::ModalCallbackFunction Class Reference

## Detailed Description

This class provides some handy utility methods for creating ModalComponentManager::Callback objects that will invoke a static function with some parameters when a modal component is dismissed.

The documentation for this class was generated from the following file:

- juce_gui_basics/components/juce_ModalComponentManager.h

## Static Public Member Functions

template<typename CallbackFn>
static ModalComponentManager::Callback * | create (CallbackFn &&fn)
| This is a utility function to create a ModalComponentManager::Callback that will call a callable object.
template<typename ParamType>
static ModalComponentManager::Callback * | create (void(*functionToCall)(int, ParamType), ParamType parameterValue)
| This is a utility function to create a ModalComponentManager::Callback that will call a static function with a parameter.
template<typename ParamType1, typename ParamType2>
static ModalComponentManager::Callback * | withParam (void(*functionToCall)(int, ParamType1, ParamType2), ParamType1 parameterValue1, ParamType2 parameterValue2)
| This is a utility function to create a ModalComponentManager::Callback that will call a static function with two custom parameters.
template<class ComponentType>
static ModalComponentManager::Callback * | forComponent (void(*functionToCall)(int, ComponentType *), ComponentType *component)
| This is a utility function to create a ModalComponentManager::Callback that will call a static function with a component.
template<class ComponentType, typename ParamType>
static ModalComponentManager::Callback * | forComponent (void(*functionToCall)(int, ComponentType *, ParamType), ComponentType *component, ParamType param)
| Creates a ModalComponentManager::Callback that will call a static function with a component.

## Member Functions

## create() [1/2]

template<typename CallbackFn>

ModalComponentManager::Callback * juce::ModalCallbackFunction::create | ( | CallbackFn && | fn | ) |

inline static

This is a utility function to create a ModalComponentManager::Callback that will call a callable object.

The function that you supply must take an integer parameter, which is the result code that was returned when the modal component was dismissed.

See also
  ModalComponentManager::Callback

References juce::NullCheckedInvocation::invoke().

Referenced by create(), forComponent(), forComponent(), and withParam().

## create() [2/2]

template<typename ParamType>

ModalComponentManager::Callback * juce::ModalCallbackFunction::create | ( | void(* | functionToCall )(int, ParamType),
|  | ParamType | parameterValue )

inline static

This is a utility function to create a ModalComponentManager::Callback that will call a static function with a parameter.

The function that you supply must take two parameters - the first being an int, which is the result code that was used when the modal component was dismissed, and the second can be a custom type. Note that this custom value will be copied and stored, so it must be a primitive type or a class that provides copy-by-value semantics.

E.g.

static void myCallbackFunction (int modalResult, double customValue)
{
if (modalResult == 1)
doSomethingWith (customValue);
}
Component* someKindOfComp;
...
someKindOfComp->enterModalState (true, ModalCallbackFunction::create (myCallbackFunction, 3.0));
juce::Component
The base class for all JUCE user-interface objects.
Definition juce_Component.h:45
juce::Component::enterModalState
void enterModalState(bool takeKeyboardFocus=true, ModalComponentManager::Callback *callback=nullptr, bool deleteWhenDismissed=false)
Puts the component into a modal state.
juce::ModalCallbackFunction::create
static ModalComponentManager::Callback * create(CallbackFn &&fn)
This is a utility function to create a ModalComponentManager::Callback that will call a callable obje...
Definition juce_ModalComponentManager.h:190

See also
  ModalComponentManager::Callback

References create().

## withParam()

template<typename ParamType1, typename ParamType2>

ModalComponentManager::Callback * juce::ModalCallbackFunction::withParam | ( | void(* | functionToCall )(int, ParamType1, ParamType2),
|  | ParamType1 | parameterValue1,
|  | ParamType2 | parameterValue2 )

inline static

This is a utility function to create a ModalComponentManager::Callback that will call a static function with two custom parameters.

The function that you supply must take three parameters - the first being an int, which is the result code that was used when the modal component was dismissed, and the next two are your custom types. Note that these custom values will be copied and stored, so they must be primitive types or classes that provide copy-by-value semantics.

E.g.

static void myCallbackFunction (int modalResult, double customValue1, String customValue2)
{
if (modalResult == 1)
doSomethingWith (customValue1, customValue2);
}
Component* someKindOfComp;
...
someKindOfComp->enterModalState (true, ModalCallbackFunction::create (myCallbackFunction, 3.0, String ("xyz")));
juce::String
The JUCE String class!
Definition juce_String.h:67

See also
  ModalComponentManager::Callback

References create().

## forComponent() [1/2]

template<class ComponentType>

ModalComponentManager::Callback * juce::ModalCallbackFunction::forComponent | ( | void(* | functionToCall )(int, ComponentType *),
|  | ComponentType * | component )

inline static

This is a utility function to create a ModalComponentManager::Callback that will call a static function with a component.

The function that you supply must take two parameters - the first being an int, which is the result code that was used when the modal component was dismissed, and the second can be a Component class. The component will be stored as a WeakReference, so that if it gets deleted before this callback is invoked, the pointer that is passed to the function will be null.

E.g.

static void myCallbackFunction (int modalResult, Slider* mySlider)
{
if (modalResult == 1 && mySlider != nullptr) // must check that mySlider isn't null in case it was deleted
mySlider->setValue (0.0);
}
Component* someKindOfComp;
Slider* mySlider;
...
someKindOfComp->enterModalState (true, ModalCallbackFunction::forComponent (myCallbackFunction, mySlider));
juce::ModalCallbackFunction::forComponent
static ModalComponentManager::Callback * forComponent(void(*functionToCall)(int, ComponentType *), ComponentType *component)
This is a utility function to create a ModalComponentManager::Callback that will call a static functi...
Definition juce_ModalComponentManager.h:292
juce::Slider
A slider control for changing a value.
Definition juce_Slider.h:110
juce::Slider::setValue
void setValue(double newValue, NotificationType notification=sendNotificationAsync)
Changes the slider's current value.

See also
  ModalComponentManager::Callback

References create().

## forComponent() [2/2]

template<class ComponentType, typename ParamType>

ModalComponentManager::Callback * juce::ModalCallbackFunction::forComponent | ( | void(* | functionToCall )(int, ComponentType *, ParamType),
|  | ComponentType * | component,
|  | ParamType | param )

inline static

Creates a ModalComponentManager::Callback that will call a static function with a component.

The function that you supply must take three parameters - the first being an int, which is the result code that was used when the modal component was dismissed, the second being a Component class, and the third being a custom type (which must be a primitive type or have copy-by-value semantics). The component will be stored as a WeakReference, so that if it gets deleted before this callback is invoked, the pointer that is passed into the function will be null.

E.g.

static void myCallbackFunction (int modalResult, Slider* mySlider, String customParam)
{
if (modalResult == 1 && mySlider != nullptr) // must check that mySlider isn't null in case it was deleted
mySlider->setName (customParam);
}
Component* someKindOfComp;
Slider* mySlider;
...
someKindOfComp->enterModalState (true, ModalCallbackFunction::forComponent (myCallbackFunction, mySlider, String ("hello")));
juce::Component::setName
virtual void setName(const String &newName)
Sets the name of this component.

See also
  ModalComponentManager::Callback

References create().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited