[Writer] Create an object that appears/disappears when clicked

Hi everyone,.
I’m trying here after having no success in the italian forum. So please be clement for my English.

In brief, I’m trying to emulate a sort of radio button. An empty small circle drawn on the document background image shoud alternately appear filled or empy when clicked.
The idea was to reach the goal creating a shape (a black circle) and arrange it for make it visible or invisible when clicked.

Clearly I’m here because I didn’t find a simple way to do that, it is necessary a better knowledge of MACRO than mine I think, even better if it is possible to do that without MACRO (avoiding the annoying warning).

I’m open to any kind of hint, event to reach the goal in a completely different way.
I can’t use the existing controls because they are not compatible with the document’s graphic design.

Thanks in advance! :slight_smile:

Link to Italian forum question added by ajlittoz

Please add to your question (edit it, don’t answer with a comment) OS name, LO version and save format.
Are you trying to design a form? In which case you should try and use the form design tools and controls.

Note that basically Writer is not intended to produce “animated” or interactive documents. Its “normal” output is print (or any “frozen” output such as screen display or file export). The form design tools are offered to partially overcome this limitation. The document can then be exported to PDF with the required option(s) enabled so that the PDF can be interactively filled.

When asking here, refrain from requesting help to complete your partial design (“solution”?) because you may not have chosen the right track. Always start from the beginning and describe the initial goal and only after that explain what you tried. We may suggest a totally different approach.

1 Like

Thanks for your fast answer.
I’ll try to fulfill your requests.

About the requested data, I’m working on Windows 10 using LO 5.2.2 (I will update it to 7.5.3. as soon as I’ll have enough free time) and the save format is the native one, .odt.
Anyway I hope the solution will work on any OS and on future versions of LO.

What I want to obtain is a document that will be compiled by the user in odf format.
After the user will compile it, he/she will print it as it appears. The final achievement is the printed document (on paper, or as PDF too, it is a static document anyway).

Inside this document, there are some (many!) “radio buttons”. I mean, thare are some empty circles that the user can decide to fill or leave empty.
In order to help this process, I placed on each circle a black circle shape that the use can delete if he/she want to leave the circle emapty. This solution in quite unconfortable in some cases.
So I’m looking for a way to make this process easier and I thought about make the black shape visible/invisible on click instead thea deleting it.
I can’t use the predefined radio button because the document has is own design and I have to fit with it.

As written above, I’m totally open to change approach if someone will soggest something I can apply to my case.

Supposing you goal is only “visual”, i.e. you want to see one of two different graphical decoration elements without any action being triggered behind the scene, this can be done by abusing the list feature of Writer.

To do this, you need to be familiar with styles and notably with list styles. If not, read the Writer Guide for an introduction and practice a bit before going further.

Create a new list style (list styles can be accessed by clicking on the fifth icon from the left in the toolbar of the side style pane – F11 if not yet visible). Name it RadioBtn or something similar to your liking.

  1. ignore all tabs except Position and Customize
    IMPORTANT: once you’ve begun to configure the style yo your liking, don’t use any other tab because they will override your settings and you’ll have to restart from the beginning.
  2. in Customize, select Level 1-10 and Number: as Bullet
  3. then for Level 1, press Select, select Character block "Geometric shapes*
    1. you should see a white square at U+25A1
    2. click on it
    3. OK
  4. for Level 2, press Select, select Character block "Dingbats*
    1. you should see a white square with a check mark at U+2611 and U+2612
    2. click on one of them
    3. OK
  5. in Position, you adjust the position of the mark and the left indent ("margin’) of the text for the “radio button”
    1. select Level 1-10
    2. set Aligned at 0cm
    3. set both Indent at and Tab stop at 1,27cm (or other distance you prefer)
      It is important that these two values always remain the same.

When you want to add a “radio button” on a paragraph, apply your RadioBtn to the paragraph (this comes in addition to any paragraph style you apply to the the paragraph). An unchecked “button” appears at left.

To check the button, put the cursor at the very beginning of the text and press Tab. To uncheck a button, put the cursor at the very beginning of the text and press Shift+Tab.

PS: these are not usual radio buttons but this is the closest I could find in the widely available Unicode glyphs. If you want real traditional radio buttons, create them in a graphical program like Draw and same them as an image (JPEG, PNG, …). Instead of selecting Number: “Bullet”, use “Graphics” and import your files.

Thanks again, interesting solution.
I’m quite confident with styles, I should note have problem to implement it.

In my case checked square are not a good solution, but use an image for “checked” and a trasparenr one for “unchecked” could work.
If I’m not wrong, you are suggesting to differenziate two levels of the list locking two different symbols (one for checked and one for unchecked) in the same position, so that it is possible to switch from unchecked to checked uppering the list level using tab.

I’ll try it, but there are two criticalities:

  • my lists are not lists. I mean, there “radio buttons” are placed in various way: vertical lists, horizontal lists, inside a larger circle, etc… Place a shape in a precise position is easy, add a paragraph could be much more complicated.
  • as the document is not created for me only, I fear this method (place the cursor and use tab to increase/decrease the list level) is too difficult for some users and surely is not self-explicative, it is necessary to explain how to use it. Clicking a circle is surely much more intuitive.

If in the meantime any other idea should come out, please don’t refrain to post it.

PS: the final document is static, but I was wondering if to add a trigger when some of the boxes are checked to help the filling of the document.

Well, you didn’t describe in detail all possible cases. I answerd for a “standard” document, such as a contract with various optional clauses. If you better explain what you need, I can imagine other solutions.
However, I feel that perhaps your document is not a “flow-oriented” one, i.e. one which is read sequentially from start to end. If you have both vertical and horizontal “lists”, it may deserve HTML design where radio buttons are readily available.
Attach a demo file to give an example of design. Use some distinctive “character” to replace your radio buttons.

Oh yes surely, I become aware that my description was incomplete after your comment, and probably it is still not exaustive.
.
Let’s try again then:
The document has an image as background.
The image is the true document and it represents a game sheet.
It contains textboxes, textfields, radiobuttons, etc… in a chaotic disposition and with a specific graphyc style. The background sheet cannot be changed.
Usually this image is printed and compiled manually.
I’m trying to create a layer of text that allows to compile it on the PC and than print it.
I easily create this layer but now I’d like to improve the document usability.
One of the things that I’d like to improve is the check/unckeck of checkboxes. The empty circles are on the background image, so I only need to fill them with black to represent che checked button.
In the present version of the document, black circular shapes do the job In the document as it works now, all the ckeckbox are checked by default and the user will delete the shapes over the boxes that have to stay unchecked. It is quite uncomfortable because the most of the box will be unchecked at the end, and it is not trivial when you have to add again a shape you deleted before (it happens quite often, when you update the sheet), because you have to place it in a specific precise position (and that’s why all the boxex are checked ad start).
So I thought: what if instead then having all the boxes checked and delete the shapes, the shape will show/hide when the user click on the box? Much more comfortable, fast and easy to manage.
And here rise the request made in this topic: how to show/hide a shape on click?
.
I hope this description is enough, because I need some time to create a sample file I can share.

Then Writer is definitively not the right tool. There are many reasons for that.

The most serious reason is related to your construction procedure. You probably used “drawing objects” (shapes) to add all your “widgets” over your images. All these shapes cannot be anchored to the background image and their positions will very easily be altered by even slight interaction with them. Any “widget” addition is supposed to be anchored to some text paragraph, but according to your description you have probably no “standard” text at tall.

Your document is rather in the form category. Your best approach is in form design. You have two options: work with Writer or work with Draw. I recommend Draw if you have really no “standard” text printed around or in the middle of the background image. And even if you have short text, this can be handled in Draw.

In Draw you can activate form tools. For best comfort in design, create several layers so that you won’t accidentally select and move objects in layers other than the one you’re working in.

In the deepest layer, import your background image. Add to it the immutable objects you need, such as title, copyright, legend. All these are text boxes. When done, lock the layer.

Create another layer over it for static objects and lock it.

Create the top layer for the user-modifiable controls. Radio buttons are readily available but remember to group them in some group (right-click to access properties and enter the name of the group). Thus, Draw will automatically manage the mark within the group.

Remember that traditionally radio buttons are made to work in groups: only one in the group can be enabled, which means any group must number at least two buttons. If your choice is a binary one (on/off, yes/no), then it is a check box, not a radio button.

You can associate a macro with a form control. If you like programming, this may be a way to “animate” your form.

I agree Writer is not the best solution, anyway… the 99% of the work is already done so let’s try to squeeze into it. :slight_smile:
.
The shapes are usually anchored to a frame that contains them. The frames are in a fixed position inside the whole sheet. I tried to make all the reference as absolute.
I agree the design is “fragile”, it is easy that an accidental delete will make loose the settings I prepared for an element but, luckily, Writer has a long “undo” list.
Draw probably is a better tool, but I’ve not confidence with it. And I don’t know if it manages enough well large text frames, allowing to apply different styles inside them.
.
About radio buttons, I called them this way because of their appearance but in terms of functionality they are more similar to checkboxes.
.
That said… let’s try to stay on Writer.
For me the clickable shapes would be a satisfying solution.
Maybe a one-click way to make invisible or 100% transparent the shape would be decent too (slow and less intuitive than the click, but solves the two problems described above).
.
I’ve some skill in programming, but I don’t know the uno API anche the programming language used by LO for the macros, so some help in this would be necessary.

Draw is very good at the job (it is a graphical program from the start). There are no text frames in Draw because it does not manage text flows. There are text boxes and you can separately format and “embellish” each word or character. Unfortunately there are no styles with the same functionality as in Writer so all your decorations are manual. A very good feature is that any shape can have a label (=text) attached to it (a text box is nothing else than a transparent rectangle with no border) and this label van be anchored anywhere relative to the shape. Consequently, for your “radio button”, you draw a circle and attach a label which you offset aside the circle. This is more user-friendly than drawing a circle and another text box for the label.

Even if your job is 99% complete, have a try at Draw to see how faster you can proceed. It may be worth to switch to Draw at a later stage if you need to change your sheet.

You could perhaps copy all from Writer and paste into Draw to avoid starting from a blank page. I didn’t test it because I work the other way: Draw → Writer.

Thanks again for the suggestion.
I’ll surely try to use Draw for a future version of the sheet, but at the moment the lack of free time and the effort to learn a new tool overwhelm me.
Draw looks very interesting, even if the lack of paragraph/character/… styles is very limiting form my workflow.

I know that it is not the best option, but there is a chance to easily realize the show/hide option I imagined with Writer?

I don’t think so unless you write some macros. This is why I mentioned this. But I never wrote any macro (having always found solutions without them), so I can’t help you there.

Thanks anyway for all the efforts.

In the meantime all’ll try to understand if what I asked is possible.
If someone familiar with MACRO want to make a try to help me, he/she is welcome.