#include "focusmanager.h" #include "widget.h" namespace SDLwidgets { void FocusManager::requestFocus( Focusable* widget ) { if ( _focused_widget && widget != _focused_widget ) { _focused_widget->focusLost(); } _focused_widget = widget; _focused_widget->focusGained(); _widget = dynamic_cast( widget ); if ( _widget ) { SDL_EnableUNICODE( 1 ); } else { SDL_EnableUNICODE( 0 ); } } void FocusManager::removeFocus( Focusable* widget ) { if ( _focused_widget && _focused_widget == widget ) { _focused_widget->focusLost(); _focused_widget = 0; _widget = 0; SDL_EnableUNICODE( 0 ); } } bool FocusManager::handleEvent( SDL_Event* event ) { if ( _widget ) { return _widget->handleEvent( event ); } return false; } }