Using ly:grob-object to access grobs with \tweak: Difference between revisions

m Replace version="2.24.0" with version="2.24" now that the LilyWiki extension supports auto-selecting the latest release in a stable series
mNo edit summary
Line 1: Line 1:
Some grobs can be accessed “laterally” from within another grob’s callback. These are usually listed as “layout objects” in the “Internal properties” section of a grob-interface. The function ly:grob-object is used to access these grobs.
Some grobs can be accessed “laterally” from within another grob’s callback. These are usually listed as “layout objects” in the “Internal properties” section of a grob interface. The function <code>ly:grob-object</code> is used to access these grobs.


Demonstrated below are some ways of accessing grobs from within a NoteHead callback, but the technique is not limited to NoteHeads. However, the NoteHead callback is particularly important, since it is the implicit callback used by the <code>\tweak</code> command.
Demonstrated below are some ways of accessing grobs from within a <code>NoteHead</code> callback, but the technique is not limited to <code>NoteHead</code>s. However, the <code>NoteHead</code> callback is particularly important, since it is the implicit callback used by the <code>\tweak</code> command.


The example function defined below (&quot;display-grobs&quot;) is probably not that useful, but it demonstrates that the grobs are indeed being accessed.
The console output of the example function below (<code>display-grobs</code>) is as follows.


Example console output:
<pre>
--------------------
#<Grob Accidental >
()
#<Grob Stem >
</pre>


<code>#&lt;Grob Accidental &gt;</code><br />
It is probably not that useful, but it demonstrates that the grobs are indeed being accessed.
<code>()</code><br />
<code>#&lt;Grob Stem &gt;</code>


<lilypond version="2.24">
<lilypond version="2.24">