MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ key_step()

Context & MayaFlux::Portal::Forma::Context::key_step ( uint32_t  id,
std::shared_ptr< MappedState< float > >  state,
IO::Keys  decrease,
IO::Keys  increase,
float  delta,
float  clamp_min = 0.0F,
float  clamp_max = 1.0F 
)

Attach key-delta handlers to a Mapped<float> element.

Binds key handlers that adjust the element's state by a delta on each press/hold. The element must be focused (via mouse click) for keys to fire.

Parameters
idElement id.
stateMappedState to adjust.
decreaseKey that decreases the value.
increaseKey that increases the value.
deltaStep size per key event.
clamp_minMinimum clamped value (default 0.0F).
clamp_maxMaximum clamped value (default 1.0F).
Returns
*this for chaining.

Definition at line 153 of file Context.cpp.

161{
162 on_held(id, decrease, [state, delta, clamp_min, clamp_max](uint32_t) {
163 state->write(std::clamp(state->value - delta, clamp_min, clamp_max));
164 });
165
166 on_held(id, increase, [state, delta, clamp_min, clamp_max](uint32_t) {
167 state->write(std::clamp(state->value + delta, clamp_min, clamp_max));
168 });
169
170 return *this;
171}
void on_held(uint32_t id, IO::Keys key, KeyFn fn)
Called repeatedly while a key is held and the element has focus.
Definition Context.cpp:100

References on_held().

+ Here is the call graph for this function: