bwidgets/inc/basic_widgets/w/feat/keyboard_handler.hpp
Andrea Blankenstijn 7c5277dabd They say members defined in header are implicitly inline.
Also remove the static from static inline (is that C specific?)
2021-08-14 09:17:51 +02:00

43 lines
1.1 KiB
C++

#ifndef BWIDGETS_KEYBOARD_HANDLER
#define BWIDGETS_KEYBOARD_HANDLER
#include <basic_widgets/w/feat/focus_handler.hpp>
struct SDL_KeyboardEvent;
struct SDL_TextInputEvent;
namespace bwidgets
{
class KeyboardHandler : public virtual FocusHandler
{
protected:
virtual void _handle_key(const SDL_KeyboardEvent&) = 0;
virtual void _handle_text_input(const SDL_TextInputEvent&) = 0;
public:
using FocusHandler::FocusHandler;
KeyboardHandler(const KeyboardHandler&) = delete;
KeyboardHandler(KeyboardHandler&&) = delete;
~KeyboardHandler() override = default;
auto operator=(const KeyboardHandler&) = delete;
auto operator=(KeyboardHandler&&) = delete;
virtual auto handle_keyboard(const SDL_KeyboardEvent& ev)
-> KeyboardHandler* final
{
if (_has_focus) _handle_key(ev);
return this;
}
virtual auto handle_keyboard(const SDL_TextInputEvent& ev)
-> KeyboardHandler* final
{
if (_has_focus) _handle_text_input(ev);
return this;
}
};
}
#endif