33 lines
713 B
C++
33 lines
713 B
C++
#ifndef BWIDGETS_FOCUS_HANDLER_IMPL_HPP
|
|
#define BWIDGETS_FOCUS_HANDLER_IMPL_HPP
|
|
|
|
#include <basic_widgets/w/feat/focus_handler.hpp>
|
|
|
|
namespace bwidgets
|
|
{
|
|
class FocusHandlerImpl : public virtual FocusHandler
|
|
{
|
|
bool _has_focus {false};
|
|
std::function<void(bool)> _focus_handler {[](auto) {}};
|
|
|
|
public:
|
|
void focus(bool focus_) override
|
|
{
|
|
_focus_handler(focus_);
|
|
_has_focus = focus_;
|
|
}
|
|
|
|
bool focus() override
|
|
{
|
|
return _has_focus;
|
|
}
|
|
|
|
void focus_handler(decltype(_focus_handler) handler) final
|
|
{
|
|
_focus_handler = std::move(handler);
|
|
}
|
|
};
|
|
}
|
|
|
|
#endif
|