Can you easily create a dropdown/spoiler in Writer?

Can you select a text and make it so that it’s only shown if you clicked the little arrow to the right of another text to activate it? And you click the arrow again to deactivate/hide it? Like this:


Title :arrow_forward:


With the arrow looking to the right, the text is hidden. Then, if you click the arrow:


Title ▼

Text text text text text text text text text text text


Is that possible to do in LibreOffice Writer?

Currently, the only way to do this is with a macro. Here is an example: expandable section.odt

expanded section

The required code is simple enough. The following was adapted from [Solved] Macro to hide/unhide a Writer section (View topic) • Apache OpenOffice Community Forum.

Sub Hide_ShowSection1
    Hide_ShowSection("Section1 Collapsed")
    Hide_ShowSection("Section1 Expanded")
End Sub
Sub Hide_ShowSection(section_name)
	ts = ThisComponent.getTextSections
	s1 = ts.getByName(section_name)
	If s1.IsVisible then
		s1.IsVisible = false
	Else
		s1.IsVisible = true
	EndIf  
End Sub

General instructions:

  • Insert two sections. In the first section named “Section1 Collapsed”, insert a frame with text “Title ⯈”.
  • In the second section named “Section1 Expanded”, add the text to be displayed, and at the top, insert a frame with text “Title ▼”.
  • For both frames, set the Click object event to run the macro Hide_ShowSection1.

Related:

Thank you!!!

Hi,
just want to ask if there is any way to change the “title” item. Haven’t found any solution - where is it stored?

Please create a new question and include a link to this question. Delete this “answer” because it is not an answer. See guidelines for asking.