20 template <
template <
typename...>
typename ContainerT,
typename ValueT>
37 template <
typename ValueT,
template <
typename...>
typename ContainerT = std::vector>
40 using namespace Attributes;
41 using namespace Elements;
43 auto attributes = std::move(args.selectAttributes);
45 attributes.push_back(onChange = [onSelect = std::move(args.onSelect), &model = args.model](
Nui::val event) {
46 const auto index = event[
"target"][
"selectedIndex"].as<long long>();
47 onSelect(index, model.value()[index]);
54 args.model.map([preSelectedIndex = args.preSelectedIndex](
auto i,
auto const& opt) {
57 selected = (i == preSelectedIndex),
Definition: observed_value.hpp:1202
Definition: dialog.hpp:11
constexpr auto Select(SelectArgs< ContainerT, ValueT > &&args)
Creates a <select><option></option>...</select> element.
Definition: select.hpp:38
emscripten::val val
Definition: val.hpp:5
Definition: select.hpp:22
std::function< void(long long, SelectOptions< ValueT > const &)> onSelect
Called when an option is selected.
Definition: select.hpp:30
Observed< ContainerT< SelectOptions< ValueT > > > & model
A list of all the options:
Definition: select.hpp:24
int preSelectedIndex
For pre selecting an element.
Definition: select.hpp:27
std::vector< Attribute > selectAttributes
Attributes to be forwarded to the select element.
Definition: select.hpp:33