Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 2 additions & 13 deletions include/oneMenu/menu/item.h
Original file line number Diff line number Diff line change
Expand Up @@ -519,19 +519,7 @@ namespace oneMenu {
};
};

/// @brief Fires fn(v) on every value mutation while editing; v is re-read via get() after Base::set() (may be clamped/transformed).
/// Compose inside NumField<...>'s range/storage chain, e.g. NumField<StaticNumRange<...>, OnChange<fn>, AsField<Watch<...>>>.
template<auto fn>
struct OnChange {
template<typename I>
struct Part:I {
using Base=I;
using Base::Base;
using Base::get;
using Type=typename Base::Type;
void set(Type v) {Base::set(v); fn(Base::get());}
};
};
using oneData::OnChange;

/// @brief Fires fn(v) once when edit mode is left (Enter-to-commit or Esc-while-editing; Esc is treated as a commit, not a cancel).
/// Compose outside (wrapping) EditField, e.g. ItemDef<..., OnUpdate<fn>, EditField, NumField<...>>.
Expand Down Expand Up @@ -912,6 +900,7 @@ namespace oneMenu {
static constexpr void enable(bool o=true) {ref.enable(o);}
[[nodiscard]] static constexpr bool changed() {return ref.changed();}
static constexpr void sync() {ref.sync();}
static decltype(auto) get() {return ref.get();} // the referred value, for a component over this node (OnSync)
static constexpr bool up() {return ref.up();}
static constexpr bool down() {return ref.down();}

Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"dependencies": {
"HAPI":">=0.7.0",
"OneChip":"https://github.com/InternetOfPins/OneChip.git",
"OneData":">=0.1.13",
"OneData":">=0.1.22",
"OneInput":"https://github.com/InternetOfPins/OneInput.git",
"OneItem":">=0.1.3",
"OneOutput":">=0.0.5",
Expand Down
Loading