Luna/gui/libui/include/ui/InputField.h

43 lines
905 B
C
Raw Normal View History

/**
* @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
{
2024-09-18 19:48:15 +00:00
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 };
};
}