FTXUI/src/ftxui/component/button.cpp

27 lines
515 B
C++
Raw Normal View History

2020-08-26 22:26:09 +08:00
#include "ftxui/component/button.hpp"
#include <functional>
namespace ftxui {
Element Button::Render() {
if (Focused())
2020-09-06 19:46:56 +08:00
return text(label) | border | inverted;
2020-08-26 22:26:09 +08:00
else
return text(label) | border;
}
bool Button::OnEvent(Event event) {
if (event == Event::Return) {
on_click();
return true;
}
return false;
}
} // namespace ftxui
// Copyright 2020 Arthur Sonzogni. All rights reserved.
// Use of this source code is governed by the MIT license that can be found in
// the LICENSE file.