title: How do I access variables within a context object in Kotlin?
body: <p>I have this code:</p>
  
  <pre><code>inner class MyGestureListener: GestureDetector.SimpleOnGestureListener() {
  
      override fun onDown(event: MotionEvent): Boolean {
          return true
      }
  
      override fun onSingleTapUp(event: MotionEvent): Boolean {
  
          val colWidth = width / (colCount + 1) // works out the width of each column
          var colTouch = event.x.toInt() / colWidth // works out what column has been selected
  
          val rowHeight = height / ((rowCount * 2) + 1)
          var rowTouch = event.y.toInt() / rowHeight
  
          return true
      }
  
  }
  </code></pre>
  
  <p>As you can see, <code>n</code> is used as a reference to the context. Within the context is an object <code>boxGame</code>. Here's an example of what I mean.</p>
  
  <p><a href="https://i.stack.imgur.com/PI4hE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PI4hE.png" alt="Screenshot of the debugging tool in Android Studio"></a></p>
  
  <p>However, I cannot figure out how I can access that object from <code>n</code>. I would have thought it would be <code>n.boxGame</code> but Android Studio flags that as wrong.</p>