Nui
text_input.hpp
Go to the documentation of this file.
1 #pragma once
2 
5 
6 // elements
8 
9 // attributes
13 
14 namespace Nui::Components
15 {
22  template <typename T, typename... Attributes>
23  constexpr auto TextInput(Observed<T>& model, Attributes&&... attributes)
24  {
25  return [&model, ... attributes = std::forward<Attributes>(attributes)]<typename... Children>(
26  Children&&... children) mutable {
27  using Nui::Elements::input;
28  namespace attr = Nui::Attributes;
29  using attr::type;
30  using attr::value;
31  using attr::onInput;
32 
33  return input{
34  std::move(attributes)...,
35  type = "text",
36  value = model,
37  onInput =
38  [&model](auto const& event) {
39  model = event["target"]["value"].template as<std::string>();
40  },
41  }(std::forward<Children>(children)...);
42  };
43  }
44 }
Definition: observed_value.hpp:1202
Definition: attribute_factory.hpp:14
Definition: dialog.hpp:11
constexpr auto TextInput(Observed< T > &model, Attributes &&... attributes)
This component can be used like this TextInput(attributes...)(children...) instead of the C{}() synta...
Definition: text_input.hpp:23