mirror of
https://github.com/ArthurSonzogni/FTXUI.git
synced 2025-09-19 01:38:08 +08:00
Add Event.
This commit is contained in:
4
examples/input/CMakeLists.txt
Normal file
4
examples/input/CMakeLists.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
add_executable(input_main
|
||||
main.cpp
|
||||
)
|
||||
target_link_libraries(input_main PRIVATE ftxui)
|
47
examples/input/main.cpp
Normal file
47
examples/input/main.cpp
Normal file
@@ -0,0 +1,47 @@
|
||||
#include <chrono>
|
||||
#include <iostream>
|
||||
#include <thread>
|
||||
|
||||
#include "ftxui/screen_interactive.hpp"
|
||||
#include "ftxui/component/input.hpp"
|
||||
#include "ftxui/component/component_vertical.hpp"
|
||||
#include "ftxui/util/string.hpp"
|
||||
|
||||
using namespace ftxui::component;
|
||||
using namespace ftxui::dom;
|
||||
|
||||
class MyComponent : ComponentVertical {
|
||||
public:
|
||||
MyComponent(ftxui::component::Delegate* delegate)
|
||||
: ComponentVertical(delegate),
|
||||
input_1(delegate->NewChild()),
|
||||
input_2(delegate->NewChild()),
|
||||
input_3(delegate->NewChild()) {
|
||||
Focus(&input_1);
|
||||
}
|
||||
|
||||
std::function<void()> on_enter = []() {};
|
||||
|
||||
private:
|
||||
Input input_1;
|
||||
Input input_2;
|
||||
Input input_3;
|
||||
|
||||
Element Render() override {
|
||||
return
|
||||
frame(
|
||||
vbox(
|
||||
hbox(text(L" input_1 : "), input_1.Render()),
|
||||
hbox(text(L" input_2 : "), input_2.Render()),
|
||||
hbox(text(L" input_3 : "), input_3.Render())
|
||||
)
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
int main(int argc, const char* argv[]) {
|
||||
ftxui::ScreenInteractive screen(60, 17);
|
||||
MyComponent component(screen.delegate());
|
||||
component.on_enter = screen.ExitLoopClosure();
|
||||
screen.Loop();
|
||||
}
|
Reference in New Issue
Block a user