@@ -342,9 +342,87 @@ defmodule Scenic.Scene do
342
342
# ============================================================================
343
343
# callback definitions
344
344
345
+ @ doc """
346
+ Invoked when the `Scene` receives input from a driver.
347
+
348
+ Input is messages sent directly from a driver, usually based on some action by the user.
349
+ This is opposed to "events", which are generated by other scenes.
350
+
351
+ When input arrives at a scene, you can consume it, or pass it along to the scene above
352
+ you in the ViewPort's supervision structure.
353
+
354
+ To consume the input and have processing stop afterward, return either a `{:halt, ...}` or
355
+ `{:noreply, ...}` value. They are effectively the same thing.
356
+
357
+ To allow the scene's parent to process the input, return `{:cont, input, state, ...}`. Note
358
+ that you can pass along the input unchanged or transform it in the process if you wish.
359
+
360
+ The callback supports all the return values of the
361
+ [`init`](https://hexdocs.pm/elixir/GenServer.html#c:handle_cast/2)
362
+ callback in [`Genserver`](https://hexdocs.pm/elixir/GenServer.html).
363
+
364
+ In addition to the normal return values defined by GenServer, a `Scene` can
365
+ add an optional `{push: graph}` term, which pushes the graph to the viewport.
366
+
367
+ This has replaced push_graph() as the preferred way to push a graph.
368
+ """
345
369
@ callback handle_input ( input :: any , context :: Context . t ( ) , state :: any ) ::
346
- { :noreply , state :: any }
347
- @ callback filter_event ( any , any , any ) :: { :cont , any , any } | { :halt , any }
370
+ { :noreply , new_state }
371
+ | { :noreply , new_state }
372
+ | { :noreply , new_state , timeout }
373
+ | { :noreply , new_state , :hibernate }
374
+ | { :noreply , new_state , opts :: response_opts ( ) }
375
+ | { :halt , new_state }
376
+ | { :halt , new_state , timeout }
377
+ | { :halt , new_state , :hibernate }
378
+ | { :halt , new_state , opts :: response_opts ( ) }
379
+ | { :cont , input , new_state }
380
+ | { :cont , input , new_state , timeout }
381
+ | { :cont , input , new_state , :hibernate }
382
+ | { :cont , input , new_state , opts :: response_opts ( ) }
383
+ | { :stop , reason , new_state }
384
+ when new_state: term , reason: term , input: term
385
+
386
+ @ doc """
387
+ Invoked when the `Scene` receives an event from another scene.
388
+
389
+ Events are messages generated by a scene, that are passed backwards up the ViewPort's
390
+ scene supervision tree. This is opposed to "input", which comes directly from the drivers.
391
+
392
+ When an event arrives at a scene, you can consume it, or pass it along to the scene above
393
+ you in the ViewPort's supervision structure.
394
+
395
+ To consume the input and have processing stop afterward, return either a `{:halt, ...}` or
396
+ `{:noreply, ...}` value. They are effectively the same thing.
397
+
398
+ To allow the scene's parent to process the input, return `{:cont, event, state, ...}`. Note
399
+ that you can pass along the event unchanged or transform it in the process if you wish.
400
+
401
+ The callback supports all the return values of the
402
+ [`init`](https://hexdocs.pm/elixir/GenServer.html#c:handle_cast/2)
403
+ callback in [`Genserver`](https://hexdocs.pm/elixir/GenServer.html).
404
+
405
+ In addition to the normal return values defined by GenServer, a `Scene` can
406
+ add an optional `{push: graph}` term, which pushes the graph to the viewport.
407
+
408
+ This has replaced push_graph() as the preferred way to push a graph.
409
+ """
410
+ @ callback filter_event ( event :: term , from :: pid , state :: term ) ::
411
+ { :noreply , new_state }
412
+ | { :noreply , new_state }
413
+ | { :noreply , new_state , timeout }
414
+ | { :noreply , new_state , :hibernate }
415
+ | { :noreply , new_state , opts :: response_opts ( ) }
416
+ | { :halt , new_state }
417
+ | { :halt , new_state , timeout }
418
+ | { :halt , new_state , :hibernate }
419
+ | { :halt , new_state , opts :: response_opts ( ) }
420
+ | { :cont , event , new_state }
421
+ | { :cont , event , new_state , timeout }
422
+ | { :cont , event , new_state , :hibernate }
423
+ | { :cont , event , new_state , opts :: response_opts ( ) }
424
+ | { :stop , reason , new_state }
425
+ when new_state: term , reason: term , event: term
348
426
349
427
@ doc """
350
428
Invoked when the `Scene` is started.
0 commit comments