NOCL  v0.1.0-2524
Modern C++ Class Library for GUI Projects
nocl::ButtonHandler Class Referenceabstract

Event handler for nocl::Button events. More...

#include <ButtonHandler.hpp>

Inheritance diagram for nocl::ButtonHandler:
Collaboration diagram for nocl::ButtonHandler:

Public Member Functions

virtual ~ButtonHandler (void)
 Destructor. More...
 
 ButtonHandler (void)
 Constructor. More...
 
virtual ButtonHandlerhandle_button_events_for (Button &button)
 Call this method for every button that needs a callback. More...
 
virtual void clicked (Button &button)=0
 Override this pure virtual in your class. More...
 

Detailed Description

Event handler for nocl::Button events.

For example:

#include <nocl/nocl.hpp>
/* This example shows how to create a nocl::TextButton
* and a nocl::ButtonHandler to handle button clicks.
*/
class MyApp : public nocl::Application, public nocl::ButtonHandler
{
public:
/* Note how we inherit from nocl::ButtonHandler and call
* handle_button_events_for() to indicate an interest in
* button events.
*/
virtual MyApp & initialize(void) override
{
ok_button.label("OK");
button_box.add_child(ok_button);
frame_window.initialize(*this, "Testing");
frame_window.add_child(button_box);
frame_window.show_all();
return *this;
}
/* This method is inherited from nocl::ButtonHandler. You must
* override it to receive a callback when the button is clicked.
*/
virtual void clicked(nocl::Button & button) override
{
std::cout << "button was clicked!" << std::endl;
}
nocl::FrameWindow frame_window;
nocl::ButtonBox button_box;
nocl::TextButton ok_button;
};
int main()
{
MyApp app;
return app.run_message_loop();
}
See also
https://developer.gnome.org/gtk3/stable/GtkButton.html#GtkButton.signals

Constructor & Destructor Documentation

◆ ~ButtonHandler()

nocl::ButtonHandler::~ButtonHandler ( void  )
virtual

Destructor.

◆ ButtonHandler()

nocl::ButtonHandler::ButtonHandler ( void  )

Constructor.

Member Function Documentation

◆ handle_button_events_for()

nocl::ButtonHandler & nocl::ButtonHandler::handle_button_events_for ( Button button)
virtual

Call this method for every button that needs a callback.

The clicked() method will be called when button is clicked.

Exceptions
nocl::ExceptionThrows if the Gtk+ widget does not map to a NOCL GUI component.
nocl::ExceptionThrows if the NOCL GUI component is not a nocl::Button.

References clicked(), nocl::GUIComponent::gtk_widget, NOCL_WHERE, and nocl::GUIComponent::widget_to_gui_component_map().

Here is the call graph for this function:

◆ clicked()

void nocl::ButtonHandler::clicked ( Button button)
pure virtual

Override this pure virtual in your class.

Referenced by handle_button_events_for().

Here is the caller graph for this function:

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