Using ly:grob-object to access grobs with \tweak: Difference between revisions
Import snippet from LSR |
mNo edit summary |
||
| (5 intermediate revisions by 2 users not shown) | |||
| 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 | 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 | 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 | The console output of the example function below (<code>display-grobs</code>) is as follows. | ||
-------------------- | |||
#<Grob Accidental > | |||
() | |||
#<Grob Stem > | |||
It is probably not that useful, but it demonstrates that the grobs are indeed being accessed. | |||
<lilypond version="2.24 | <lilypond version="2.24"> | ||
#(define (notehead-get-accidental notehead) | #(define (notehead-get-accidental notehead) | ||
;; notehead is grob | ;; notehead is grob | ||
| Line 51: | Line 52: | ||
</lilypond> | </lilypond> | ||
[[Category:Scheme]] | [[Category:Scheme]] | ||
[[Category:Tweaks and overrides]] | [[Category:Tweaks and overrides]] | ||
[[Category:Included in the official documentation]] | [[Category:Included in the official documentation]] | ||
[[Category:Snippet]] | |||