title: Kivy: Bring widget to front
body: <p>Images in <em>ActionBar</em> overlap <em>Toolbar</em>. (<em>Toolbar</em> is <em><a href="http://kivy.org/docs/api-kivy.uix.bubble.html" rel="nofollow noreferrer">Bubble</a></em> with <em>Label</em>)<br>
  My code is based on <a href="https://stackoverflow.com/questions/34468909/how-to-make-tooltip-using-kivy/34471497#34471497">this</a> answer.</p>
  
  <p><strong>Example for ActionBar button:</strong></p>
  
  <pre><code>TooltipButton:
      icon: 'images/32/quit.png'
      text: _('Quit')
      on_press: quit()
  </code></pre>
  
  <p><strong>TooltipButton class:</strong></p>
  
  <pre><code>class TooltipButton(ActionButton):
      tooltip = Tooltip()
  
      def __init__(self, **kwargs):
          Window.bind(mouse_pos=self.on_mouse_pos)
          super(ActionButton, self).__init__(**kwargs)
  
      def on_mouse_pos(self, *args):
          if not self.get_root_window():
              return
          pos = args[1]
          self.tooltip.pos = pos
          Clock.unschedule(self.display_tooltip)  # cancel scheduled event since I moved the cursor
          self.close_tooltip()  # close if it's opened
          if self.collide_point(*self.to_widget(*pos)):
              Clock.schedule_once(self.display_tooltip, 1)
  
      def close_tooltip(self, *args):
          self.remove_widget(self.tooltip)
  
      def display_tooltip(self, *args):
          self.tooltip.tip.text = self.text
          self.add_widget(self.tooltip)
  </code></pre>
  
  <p><strong>Tooltip rule <em>(superclass is Bubble)</em>:</strong></p>
  
  <pre><code>&lt;Tooltip&gt;:
      tip: tip
      Label:
          id: tip
          text_size: self.size
          halign: 'center'
          text: 'Tip'
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/X6T5S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/X6T5S.png" alt="enter image description here"></a> </p>