Support Forum       G3D Web Page     
Public Member Functions | List of all members
G3D::GuiControl::Callback Class Reference

Base class for GuiButton pre-event handlers. More...

Public Member Functions

 Callback ()
 
 Callback (std::function< void(void)> function)
 Create a callback from a function, e.g., GuiControl::Callback(&printWarning) More...
 
template<class Class >
 Callback (Class *const object, void(Class::*method)())
 Create a callback from a class and method of no arguments, e.g., App* app = ...; Callback( app, &App::endProgram ); . More...
 
template<class Class >
 Callback (const shared_ptr< Class > &object, void(Class::*method)())
 Create a callback from a reference counted class and method of no arguments, e.g.,. More...
 
 Callback (const Callback &c)
 Copy constructor. More...
 
virtual void execute ()
 Execute the callback. More...
 
Callbackoperator= (const Callback &c)
 Assignment. More...
 

Detailed Description

Base class for GuiButton pre-event handlers.

You may subclass this and override execute or simply use one of the provided constructors.

Constructor & Destructor Documentation

◆ Callback() [1/5]

G3D::GuiControl::Callback::Callback ( )
inline

◆ Callback() [2/5]

G3D::GuiControl::Callback::Callback ( std::function< void(void)>  function)
inline

Create a callback from a function, e.g., GuiControl::Callback(&printWarning)

◆ Callback() [3/5]

template<class Class >
G3D::GuiControl::Callback::Callback ( Class *const  object,
void(Class::*)()  method 
)
inline

Create a callback from a class and method of no arguments, e.g., App* app = ...; Callback( app, &App::endProgram ); .

If the method is defined on a base class and not overriden in the derived class, you must cast the pointer: Callback(static_cast<Base*>(ptr), &Base::method);

◆ Callback() [4/5]

template<class Class >
G3D::GuiControl::Callback::Callback ( const shared_ptr< Class > &  object,
void(Class::*)()  method 
)
inline

Create a callback from a reference counted class and method of no arguments, e.g.,.

shared_ptr<Player> player = ...;
pane->addButton("Jump", GuiControl::Callback(player, &Player::jump));

◆ Callback() [5/5]

G3D::GuiControl::Callback::Callback ( const Callback c)
inline

Copy constructor.

Member Function Documentation

◆ execute()

virtual void G3D::GuiControl::Callback::execute ( )
inlinevirtual

Execute the callback.

◆ operator=()

Callback& G3D::GuiControl::Callback::operator= ( const Callback c)
inline

Assignment.


documentation generated on Wed Nov 24 2021 08:01:56 using doxygen 1.8.15