class_docstr: SDL2 backend for Canvas abstract class.
class_docstr_tok: ["SDL2","backend","for","Canvas","abstract","class","."]
code: def _on_event(self, event):
      if self._vispy_canvas is None:
          return
      # triage event to proper handler
      if event.type == sdl2.SDL_QUIT:
          self._vispy_canvas.close()
      elif event.type == sdl2.SDL_WINDOWEVENT:
          if event.window.event == sdl2.SDL_WINDOWEVENT_RESIZED:
              w, h = event.window.data1, event.window.data2
              self._vispy_canvas.events.resize(size=(w, h))
          elif event.window.event == sdl2.SDL_WINDOWEVENT_CLOSE:
              self._vispy_canvas.close()
      elif event.type == sdl2.SDL_MOUSEMOTION:
          x, y = event.motion.x, event.motion.y
          self._vispy_mouse_move(pos=(x, y), modifiers=self._mods)
      elif event.type in (
          sdl2.SDL_MOUSEBUTTONDOWN,
          sdl2.SDL_MOUSEBUTTONUP,
      ):
          x, y = event.button.x, event.button.y
          button = event.button.button
          if button in BUTTONMAP:
              button = BUTTONMAP.get(button, 0)
              if event.type == sdl2.SDL_MOUSEBUTTONDOWN:
                  func = self._vispy_mouse_press
              else:
                  func = self._vispy_mouse_release
              func(pos=(x, y), button=button, modifiers=self._mods)
      elif event.type == sdl2.SDL_MOUSEWHEEL:
          pos = self._get_mouse_position()
          delta = float(event.wheel.x), float(event.wheel.y)
          self._vispy_canvas.events.mouse_wheel(
              pos=pos, delta=delta, modifiers=self._mods
          )
      elif event.type in (sdl2.SDL_KEYDOWN, sdl2.SDL_KEYUP):
          down = event.type == sdl2.SDL_KEYDOWN
          keysym = event.key.keysym
          mods = keysym.mod
          key = keysym.sym
          self._process_mod(mods, down)
          if key in KEYMAP:
              key, text = KEYMAP[key], ""
          elif key >= 32 and key <= 127:
              key, text = keys.Key(chr(key)), chr(key)
          else:
              key, text = None, ""
          if down:
              fun = self._vispy_canvas.events.key_press
          else:
              fun = self._vispy_canvas.events.key_release
          fun(key=key, text=text, modifiers=self._mods)
  
imports: from __future__ import division
  import atexit
  import ctypes
  from time import sleep
  import warnings
  import gc
  from ..base import BaseApplicationBackend, BaseCanvasBackend, BaseTimerBackend
  from ...util import keys, logger
  from ...util.ptime import time
  from ...None import config
label_desc: Use image node_id 17 for calling the CanvasBackend obj's underlying member method code with example usage: obj._on_event(event) without return types