Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarthur committed Oct 3, 2024
1 parent 9b39ce0 commit 63c450e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion ReferenceTests/src/tests/figures_and_makielayout.jl
Original file line number Diff line number Diff line change
Expand Up @@ -410,4 +410,44 @@ end
Makie.Checkbox(f[2, 4], checked = false, checkboxcolor_unchecked = :yellow)
Makie.Checkbox(f[2, 5], checked = true, checkboxcolor_checked = :orange)
f
end
end

@reference_test "Textbox" begin
f = Figure()

tb1 = Makie.Textbox(f[1,1])
Makie.set!(tb1, "1234567890qwertyuiop")
Makie.focus!(tb1)
f.scene.events.mouseposition[] = (297, 221)
f.scene.events.mousebutton[] = Makie.MouseButtonEvent(Makie.Mouse.left, Makie.Mouse.press)
Makie.defocus!(tb1)

tb2 = Makie.Textbox(f[2,1], width=100)
Makie.set!(tb2, "1234567890qwertyuiop")
tb2.cursorindex[] = 20
Makie.focus!(tb2)
f.scene.events.keyboardbutton[] = Makie.KeyEvent(Makie.Keyboard.backspace, Makie.Keyboard.press)
Makie.defocus!(tb2)

tb3 = Makie.Textbox(f[3,1], width=100)
Makie.set!(tb3, "1234567890qwertyuiop")
tb3.cursorindex[] = 20
Makie.focus!(tb3)
f.scene.events.mouseposition[] = (259, 173) # between 7 and 8
f.scene.events.mousebutton[] = Makie.MouseButtonEvent(Makie.Mouse.left, Makie.Mouse.press)
f.scene.events.keyboardbutton[] = Makie.KeyEvent(Makie.Keyboard.left, Makie.Keyboard.press)
f.scene.events.keyboardbutton[] = Makie.KeyEvent(Makie.Keyboard.left, Makie.Keyboard.press)
Makie.defocus!(tb3)

tb4 = Makie.Textbox(f[4,1], width=100)
Makie.set!(tb4, "1234567890qwertyuiop")
tb4.cursorindex[] = 20
tb4.cursorindex[] = 10
Makie.focus!(tb4)
for _ in 1:8
f.scene.events.keyboardbutton[] = Makie.KeyEvent(Makie.Keyboard.backspace, Makie.Keyboard.press)
end
Makie.defocus!(tb4)

f
end

0 comments on commit 63c450e

Please sign in to comment.