Search code examples
lilypond

Lilypond: how to add a balloon-text for clefs?


With `balloonGrobText' one can add a balloon for grob. But this does appearently not work for clefs.

Example:

\version "2.20.0"

\new Voice \with { \consists Balloon_engraver }{
  \override Voice.BalloonTextItem.annotation-balloon = ##f
  g'4
  \balloonGrobText #'Flag #'(1 . -2) \markup{"Flag"}
  \balloonGrobText #'Clef #'(1 . 2) \markup{"Clef"}
  \clef F
  b8
}

gives: Balloon text missing for clef

How to add the balloon-text for the F-clef?


Solution

  • You've put the balloon engraver in the Voice context, but Clef is part of the Staff context. Simply put it in the Staff context and it will work as expected.

    Here's how I would rewrite your example:

    \version "2.20.0"
    
    \new Staff \with {
      \consists Balloon_engraver
      \override BalloonTextItem.annotation-balloon = ##f
    }
    {
      g'4
      \balloonGrobText #'Flag #'(1 . -2) \markup{"Flag"}
      \balloonGrobText #'Clef #'(1 . 2) \markup{"Clef"}
      \clef F
      b8
    }