0

Since a Label in a PopupMenuItem, I thinks it can be set a pango text here.

PopupMenuItem: A PopupBaseMenuItem that displays text in a St.Label.

const item = new PopupMenu.PopupMenuItem("");
item.actor.set_size(300,150);   <--- effect.
item.actor.create_pango_layout('<span foreground="blue" size="32">fname</span>');  <- not effect
item.actor.set_markup('<span foreground="blue" size="32">fname</span>'); <-- fail, but it worked in vala.

I read popupMenu.js source code before, but now I forgot the url.

eexpress
  • 386
  • 1
  • 14

1 Answers1

1

You probably want to set this on the internal Clutter.Text of the PopupMenu.PopupMenuItems's St.Label:

const item = new PopupMenu.PopupMenuItem('');

item.label.clutter_text.set_markup(
  '<span foreground="blue" size="32">fname</span>');

You can bookmark this link to the whole directory of GNOME Shell's UI:

https://gitlab.gnome.org/GNOME/gnome-shell/tree/main/js/ui

andy.holmes
  • 3,383
  • 17
  • 28
  • St.Label.clutter-text is readonly refer to (https://gjs-docs.gnome.org/st10~1.0_api/st.label). Maybe St.Label is not same as Gtk.Label. – eexpress Jan 22 '22 at 08:16
  • It works now. thanks. the `size` has no effect. `font_desc` take effect. – eexpress Jan 22 '22 at 12:45