Create a new widget that wraps around an existing one, with a value transformation.
This function creates a so-called high-level widget: it returns your existing widget, but with additional functionality. You can use it in your package
Example
A simple example to get the point accross:
function RepeatedTextSlider(text::String)
old_widget = PlutoUI.Slider(1:10)
# our transformation function
transform = input -> repeat(text, input)
# use `transformed_value` to add the value tranformation to our widget
new_widget = transformed_value(transform, old_widget)
return new_widget
end
@bind greeting RepeatedTextSlider("hello")
# moving the slider to the right...
greeting == "hellohellohello"
This function is very useful in combination with PlutoUI.combine. Let's enhance our previous example by adding a text box where the repeated text can be entered. If you have not used PlutoUI.combine yet, you should read about that first.
function RepeatedTextSlider()
old_widget = PlutoUI.combine() do Child
md""" $(Child(PlutoUI.TextField())) $(Child(PlutoUI.Slider(1:10)))"""
end
# Note that the input to `transform` is now a Tuple!
# (This is the output of `PlutoUI.combine`)
transform = input -> repeat(input[1], input[2])
# use `transformed_value` to add the value tranformation to our widget
new_widget = transformed_value(transform, old_widget)
return new_widget
end
Create a new widget that wraps around an existing one, with a value transformation.
This function creates a so-called high-level widget: it returns your existing widget, but with additional functionality. You can use it in your package
Example
A simple example to get the point accross:
This function is very useful in combination with
PlutoUI.combine
. Let's enhance our previous example by adding a text box where the repeated text can be entered. If you have not usedPlutoUI.combine
yet, you should read about that first.