diff --git a/src/glfw3.jl b/src/glfw3.jl index 81451b2..8cda544 100644 --- a/src/glfw3.jl +++ b/src/glfw3.jl @@ -8,6 +8,15 @@ PRESS = 1 REPEAT = 2 end +# GetKey is defined below to return a Bool, but in the documentation it is +# defined as returning PRESS or RELEASE. In C that doesn't matter, but in +# Julia these are different types and so e.g. +# `GLFW.GetKey(window, GLFW.KEY_ESCAPE)) == GLFW.PRESS` will always return +# false. +# +# This method tells Julia how to compare an Action and a Bool so that code +# calling GetKey as documented will work as expected. +Base.(==)(b::Bool, a::Action) = b == Integer(a) @enum Key::Cint begin # Unknown key diff --git a/test/runtests.jl b/test/runtests.jl index 5cfe346..396b6eb 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -9,6 +9,10 @@ println(GLFW.GetVersionString()) # GLFWError uses integer for unrecognized error code @test isa(GLFW.GLFWError(0xDEADBEEF, "").code, Integer) +# https://github.com/JuliaGL/GLFW.jl/pull/225 +@test GLFW.PRESS == true +@test GLFW.RELEASE == false + if !haskey(ENV, "CI") # AppVeyor and Travis CI don't support OpenGL include("windowclose.jl") end