apio
53f8a583dc
Some checks failed
Build and test / build (push) Failing after 1m21s
This commit adds an error-propagating constructor for Action and Function, which makes them usable in the kernel.
43 lines
905 B
C++
43 lines
905 B
C++
/**
|
|
* @file InputField.h
|
|
* @author apio (cloudapio.eu)
|
|
* @brief Single line text input widget.
|
|
*
|
|
* @copyright Copyright (c) 2024, the Luna authors.
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
#include <luna/Action.h>
|
|
#include <ui/Font.h>
|
|
#include <ui/TextInput.h>
|
|
|
|
namespace ui
|
|
{
|
|
class InputField final : public ui::TextInput
|
|
{
|
|
public:
|
|
InputField(SharedPtr<ui::Font> font);
|
|
|
|
Result<ui::EventResult> handle_key_event(const ui::KeyEventRequest& request) override;
|
|
|
|
Result<void> draw(ui::Canvas& canvas) override;
|
|
|
|
void clear();
|
|
|
|
StringView data();
|
|
|
|
void on_submit(Function<StringView>&& action)
|
|
{
|
|
m_on_submit_action = move(action);
|
|
m_has_on_submit_action = true;
|
|
}
|
|
|
|
private:
|
|
SharedPtr<ui::Font> m_font;
|
|
|
|
Function<StringView> m_on_submit_action;
|
|
bool m_has_on_submit_action { false };
|
|
};
|
|
}
|