2020-08-26 22:26:09 +08:00
|
|
|
#ifndef FTXUI_COMPONENT_BUTTON_HPP
|
|
|
|
#define FTXUI_COMPONENT_BUTTON_HPP
|
|
|
|
|
|
|
|
#include <functional>
|
2021-05-02 02:40:35 +08:00
|
|
|
#include <string>
|
2020-08-26 22:26:09 +08:00
|
|
|
|
|
|
|
#include "ftxui/component/component.hpp"
|
2021-05-02 02:40:35 +08:00
|
|
|
#include "ftxui/dom/elements.hpp"
|
|
|
|
#include "ftxui/screen/box.hpp"
|
2020-08-26 22:26:09 +08:00
|
|
|
|
|
|
|
namespace ftxui {
|
2021-05-02 02:40:35 +08:00
|
|
|
struct Event;
|
2020-08-26 22:26:09 +08:00
|
|
|
|
|
|
|
/// @brief A button. An action is associated to the click event.
|
|
|
|
/// @ingroup dom
|
|
|
|
class Button : public Component {
|
|
|
|
public:
|
|
|
|
// Constructor.
|
|
|
|
Button() = default;
|
|
|
|
Button(std::wstring label) : label(label) {}
|
|
|
|
~Button() override = default;
|
|
|
|
|
|
|
|
/// The Button label.
|
|
|
|
std::wstring label = L"button";
|
|
|
|
|
|
|
|
/// Called when the user press the "enter" button.
|
|
|
|
std::function<void()> on_click = [] {};
|
|
|
|
|
|
|
|
// Component implementation.
|
|
|
|
Element Render() override;
|
|
|
|
bool OnEvent(Event) override;
|
2021-05-02 02:40:35 +08:00
|
|
|
|
2021-04-19 04:33:41 +08:00
|
|
|
private:
|
|
|
|
Box box_;
|
2020-08-26 22:26:09 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace ftxui
|
|
|
|
|
|
|
|
#endif /* end of include guard: FTXUI_COMPONENT_BUTTON_HPP */
|
|
|
|
|
|
|
|
// 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.
|