I can’t seem to get click events in my scenic code. I’m using scenic 0.9.0 and scenic_driver_glfw 0.9.0. I’m on a Macbook with glfw 3.2.1 and glew 2.1.0. Elixir 1.7.4, OTP 21.
The simplest reproduction I have so far is that I run mix scenic.new home, cd home and then I edit the lib/scenes/home.ex and I add:
def handle_input(event, _context, state) do
require Logger
Logger.info "#{inspect(event)}"
{:noreply, state}
end
For any input that is position dependent (i.e. cursor input) you need to have a target to receive the input. Try adding this to your graph (you can add it to the end of the @graph definition):
If you want to capture cursor position for the whole screen then you can create a transparent rectangle that covers the entire viewport (here’s a semi real-life example of that from some of my code)
I would expect to see cursor_enter events as well but you may need to call Scenic.ViewPort.capture_input/2 for that.
I just didn’t realize that a Scene did not act like a position-based input on its own. I think clear rectangle over my whole viewport will work great for my use-case (a pixel-y game for my son).