Textbox
Проверка
Атрибут validator используется вместе с validate_textbox(string, validator) для определения допустимости текущей строки. Это может быть регулярное выражение (Regex), которое должно соответствовать всей строке, или функция (Function), принимающая строку (String) в качестве входных данных и возвращающая логическое значение (Bool). Если средство проверки имеет тип T (например, Float64), проверка будет иметь вид tryparse(T, string). Textbox не позволит отправить введенное значение, если проверка не пройдена.
using CairoMakie
f = Figure()
tb = Textbox(f[2, 1], placeholder = "Enter a frequency",
validator = Float64, tellwidth = false)
frequency = Observable(1.0)
on(tb.stored_string) do s
frequency[] = parse(Float64, s)
end
xs = 0:0.01:10
sinecurve = @lift(sin.($frequency .* xs))
lines(f[1, 1], xs, sinecurve)
f
Атрибуты
MarkdownAST.Heading(3)
Defaults to Inside()
The alignment of the textbox in its suggested bounding box.
MarkdownAST.Heading(3)
Defaults to RGBf(0.8, 0.8, 0.8)
Color of the box border.
MarkdownAST.Heading(3)
Defaults to COLOR_ACCENT[]
Color of the box border when focused.
MarkdownAST.Heading(3)
Defaults to RGBf(1, 0, 0)
Color of the box border when focused and invalid.
MarkdownAST.Heading(3)
Defaults to COLOR_ACCENT_DIMMED[]
Color of the box border when hovered.
MarkdownAST.Heading(3)
Defaults to 1.0
Width of the box border.
MarkdownAST.Heading(3)
Defaults to :transparent
Color of the box.
MarkdownAST.Heading(3)
Defaults to :transparent
Color of the box when focused.
MarkdownAST.Heading(3)
Defaults to RGBAf(1, 0, 0, 0.3)
Color of the box when focused.
MarkdownAST.Heading(3)
Defaults to :transparent
Color of the box when hovered.
MarkdownAST.Heading(3)
Defaults to 5
Corner radius of text box.
MarkdownAST.Heading(3)
Defaults to 20
Corner segments of one rounded corner.
MarkdownAST.Heading(3)
Defaults to :transparent
The color of the cursor.
MarkdownAST.Heading(3)
Defaults to true
Controls if the textbox is defocused when a string is submitted.
MarkdownAST.Heading(3)
Defaults to nothing
The currently displayed string (for internal use).
MarkdownAST.Heading(3)
Defaults to false
If the textbox is focused and receives text input.
MarkdownAST.Heading(3)
Defaults to :regular
Font family.
MarkdownAST.Heading(3)
Defaults to @inherit :fontsize 16.0f0
Text size.
MarkdownAST.Heading(3)
Defaults to :center
The horizontal alignment of the textbox in its suggested bounding box.
MarkdownAST.Heading(3)
Defaults to Auto()
The height setting of the textbox.
MarkdownAST.Heading(3)
Defaults to "Click to edit..."
A placeholder text that is displayed when the saved string is nothing.
MarkdownAST.Heading(3)
Defaults to false
Controls if the displayed text is reset to the stored text when defocusing the textbox without submitting.
MarkdownAST.Heading(3)
Defaults to nothing
Restricts the allowed unicode input via is_allowed(char, restriction).
MarkdownAST.Heading(3)
Defaults to nothing
The currently stored string.
MarkdownAST.Heading(3)
Defaults to true
Controls if the parent layout can adjust to this element’s height.
MarkdownAST.Heading(3)
Defaults to true
Controls if the parent layout can adjust to this element’s width.
MarkdownAST.Heading(3)
Defaults to @inherit :textcolor :black
Text color.
MarkdownAST.Heading(3)
Defaults to RGBf(0.5, 0.5, 0.5)
Text color for the placeholder.
MarkdownAST.Heading(3)
Defaults to (8, 8, 8, 8)
Padding of the text against the box.
MarkdownAST.Heading(3)
Defaults to str->begin true end
Validator that is called with validate_textbox(string, validator) to determine if the current string is valid. Can by default be a RegEx that needs to match the complete string, or a function taking a string as input and returning a Bool. If the validator is a type T (for example Float64), validation will be tryparse(T, string).
MarkdownAST.Heading(3)
Defaults to :center
The vertical alignment of the textbox in its suggested bounding box.
MarkdownAST.Heading(3)
Defaults to Auto()
The width setting of the textbox.