cgv
Loading...
Searching...
No Matches
cgv::gui::event_handler Class Referenceabstract

interface for all classes that want to receive events More...

#include <event_handler.h>

Inheritance diagram for cgv::gui::event_handler:
cgv::base::traverse_policy cgv::app::gizmo cgv::app::overlay cgv::gui::key_control< T > cgv::gui::key_control< bool > vr_emulator vr_test cgv::app::transformation_gizmo cgv::app::canvas_overlay cgv::app::navigator cgv::app::themed_canvas_overlay cgv::app::color_map_editor cgv::app::color_map_legend cgv::app::color_selector cgv::app::performance_monitor

Public Member Functions

 event_handler ()
 default construction
 
bool grab_focus ()
 grab the focus in all parent nodes
 
virtual bool handle (event &e)=0
 overload and implement this method to handle events
 
virtual void stream_help (std::ostream &os)=0
 overload to stream help information to the given output stream
 
bool add_key_control (const std::string &property, const std::string &options, cgv::base::group_ptr group=cgv::base::group_ptr())
 add a key control for the given property with the given options.
 
- Public Member Functions inherited from cgv::base::traverse_policy
 traverse_policy (int _policy=TP_ALL+TP_STOP_ON_SUCCESS, bool _active=true, int _focus=-1)
 construct default traverse policy that visits everything
 
int get_policy () const
 return the policy without the stop on success flag
 
bool stop_on_success () const
 return whether to stop on success
 
bool stop_on_failure () const
 return whether to stop on failure
 
void set_policy (int _policy)
 set a new policy, always add stop on success flag if needed
 
int get_focused_child () const
 return the focused child or -1 if none is focused
 
void set_focused_child (int _focused_child)
 set the focused child
 
bool get_active () const
 return whether the current node is active
 
void set_active (bool _active)
 set the active flag of the current node
 

Additional Inherited Members

- Protected Attributes inherited from cgv::base::traverse_policy
TraversePolicy policy
 
bool active
 
int focus
 

Detailed Description

interface for all classes that want to receive events

Definition at line 14 of file event_handler.h.

Constructor & Destructor Documentation

◆ event_handler()

cgv::gui::event_handler::event_handler ( )

default construction

Definition at line 11 of file event_handler.cxx.

Member Function Documentation

◆ add_key_control()

bool cgv::gui::event_handler::add_key_control ( const std::string &  property,
const std::string &  options,
cgv::base::group_ptr  group = cgv::base::group_ptr() 
)

add a key control for the given property with the given options.

grab the focus in all parent nodes

This should be called in classes derived from cgv::base::group and event_handler. The group argument should be the this pointer cast to cgv::base_group. If group is not given, a dynamic_cast is performed on the this pointer.

Definition at line 22 of file event_handler.cxx.

References cgv::base::group::append_child(), cgv::data::ref_ptr< T, is_ref_counted >::empty(), cgv::base::base::find_member_ptr(), and cgv::base::base::on_set().

◆ grab_focus()

bool cgv::gui::event_handler::grab_focus ( )

grab the focus in all parent nodes

Definition at line 16 of file event_handler.cxx.

References cgv::base::grab_focus().

◆ handle()

virtual bool cgv::gui::event_handler::handle ( event e)
pure virtual

overload and implement this method to handle events

Parameters
eto be handled event (use e.get_kind() to check event type)
Returns
return true for handled events and false otherwise. Other event handlers (e.g. parents) only receive unhandled events if false is returned

Implemented in cgv::app::overlay, vr_test, vr_emulator, cgv::app::gizmo, cgv::gui::key_control< T >, and cgv::gui::key_control< bool >.

Referenced by cgv::gui::vr_server::dispatch(), and cgv::gui::vr_server::grab_focus().

◆ stream_help()

virtual void cgv::gui::event_handler::stream_help ( std::ostream &  os)
pure virtual

overload to stream help information to the given output stream

Implemented in cgv::gui::key_control< T >, cgv::gui::key_control< bool >, cgv::app::navigator, cgv::app::overlay, vr_test, vr_emulator, and cgv::app::gizmo.


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