# Makie - trouble using both a slider and textbox to change a number

**URL:** <https://discourse.julialang.org/t/makie-trouble-using-both-a-slider-and-textbox-to-change-a-number/73276>\
**Category:** Visualization\
**Tags:** makie\
**Created:** [December 17, 2021, 5:45pm UTC](https://discourse.julialang.org/t/makie-trouble-using-both-a-slider-and-textbox-to-change-a-number/73276 "2021-12-17T17:45:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JoshL](https://avatars.discourse-cdn.com/v4/letter/j/ea666f/32.png) [@JoshL](https://discourse.julialang.org/u/JoshL)\
**Post date:** [December 17, 2021, 5:45pm UTC](https://discourse.julialang.org/t/makie-trouble-using-both-a-slider-and-textbox-to-change-a-number/73276/1 "2021-12-17T17:45:36Z")

</div>

I’m running into some issues trying to use Makie to visualize some of my data using Julia 1.6.0. I’ve created a toy example below that illustrates the problem. In the example, I have a number between 0 and 1, and I want to be able to change that number using either a slider or by manually inputting the number into the textbox. The Figure contains 3 parts:

1. A display for the current number
2. The Slider allowing me to change that number
3. A Textbox displaying the number and allowing me to edit it (instead of using the slider)

The key is that I want the Slider (2) and the Textbox (3) to be in sync; if I set the Slider to the halfway point then I want the Textbox to read “0.5” and similarly if I set the Textbox to “0.75” then I want the Slider to automatically move to the 3/4 point. The code below works until I try to use too many decimal places when I input to the Textbox. So, for example, inputting “0.75” or “0.750” works as expected. However, inputting “0.750000000” causes an error, although the output in the Figure will be correct.

```julia
using GLMakie

fig = Figure()

current_number = Node(0.0)

# Label to display the value of "current_number"
Label(fig[1, 1], @lift(string($current_number)), textsize = 20)

# Slider to change the current number
number_slider = Slider(fig[2, 1], range = 0.0:0.05:1.0, startvalue = 0.0)
connect!(current_number, number_slider.value)

# Number textbox - input a number to change the displayed number
function validate_0to1(input)
    input_num = tryparse(Float64, input)

    if isnothing(input_num)
        return(false)
    end

    if input_num >= 0.0 && input_num <= 1.0
        return(true)
    else
        return(false)
    end

end

number_textbox = Textbox(fig[3, 1],
    validator = validate_0to1,
    placeholder = "0.000",
    displayed_string = @lift(string($current_number)))

on(number_textbox.stored_string) do s
    input_number = parse(Float64, s)
    set_close_to!(number_slider, input_number)
end

```

I assume my mistake probably has something to do with how I have set up the observables, but so far I have not been able to figure out what is wrong. The error I get is:

```julia
MethodError: Cannot `convert` an object of type Nothing to an object of type Vector{Point{2, Float32}}

```

Thanks in advance!

---

<div class="post-metadata">

**Author:** ![rafael.guerra](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rafael.guerra/32/216610_2.png) [@rafael.guerra](https://discourse.julialang.org/u/rafael.guerra)\
**Post date:** [December 17, 2025, 8:29pm UTC](https://discourse.julialang.org/t/makie-trouble-using-both-a-slider-and-textbox-to-change-a-number/73276/2 "2025-12-17T20:29:34Z")

</div>

Have you found a solution to this problem?

FWIW, the following slight modification of your code seems to work (GLMakie v0.13.8):

```julia-auto
using GLMakie

fig = Figure(size=(600,600))

current_number = Observable(0.0)

# Label to display the value of "current_number"
Label(fig[1, 1], @lift(string($current_number)), fontsize=20, width=300)

# Slider to change the current number
number_slider = Slider(fig[2, 1], range = 0.0:0.05:1.0, startvalue=0.0, width=300)
connect!(current_number, number_slider.value)

# Number textbox - input a number to change the displayed number
function validate_0to1(input)
    input_num = tryparse(Float64, input)
    isnothing(input_num) && return(false)
    (input_num >= 0.0 && input_num <= 1.0) ? true : false
end

number_textbox = Textbox(fig[3, 1],
    validator = validate_0to1,
    placeholder = "0.000",
    displayed_string = @lift(string($current_number)))

on(number_textbox.stored_string) do s
    input_number = parse(Float64, s)
    set_close_to!(number_slider, input_number)
end

display(fig)

```
