How to highlight a custom icon in the standard toolbar from basic code to reflect the current state like § one?

Context: LO 7.3.7.2, French version, Fmt .odt and .docx, GNU/Linux Ubuntu 22.04, Windows 10, novel writer, compatibility with .docx for external editors.

Hi everybody,

I have a Basic macro which toggles the behavior of the Enter key (when in dialogs it spits out an mdash and sets the current paragraph to a given style). Works fine.
I also have a custom button, in the standard toolbar, to enable the toggling of that behavior. Works fine.
But I also would like to show the current state On or Off by highlighting the button exactly as the § button, when the display of special characters is On.

What properties do I need to access to read the current state of the button and set it to the other state, by either highlighting or dis-highligting?

Thx in advance for your tips!

Kind regards,
Bernard

IMHO you’re on a wrong track. I see two possible work flows.

Use an AutoText entry to enter your em-dash and switch to another paragraph style. Call the AutoText after a manually entered paragraph break (you could encode the paragraph break in your AutoText but it probably makes things less versatile).

Consider your “dialogue paragraph” is in fact a list item where the bullet is an em-dash. Since you already have a specific paragraph style, all you have to do is to attach a list style to the style definition in the Outline & List tab. To avoid possible unintended interaction with real lists, create a custom list style for that.

How to use the second suggestion?

Create a keyboard shortcut for your dialogue style, e.g. Ctrl+9 (easy to hit on the numeric keypad). This is done in Tools>Customize, Keyboard tab.

  1. hit Enter to end the previous paragraph
  2. press Ctrl+9 to switch to “dialogue”
    Further Enter hits provide additional “dialogue” lines.
  3. press Ctrl+0 to return to Body Text, the "standard* style for narrative.

You can tell the current “mode” by looking at the active paragraph style in the status bar.


PS: for most accurate advice, always mention OS name, LO version and save format.

Many thanks for your suggestions. I have updated my initial post to add the context as per your advice.

Alas, the AutoText solution will be too slow in terms of number of keystrokes per hour.

And the second one is really a nice solution, but we are using it for several years now. The reason why I implemented the alternative way of handling the CR, is for a better compatibility with the .docx and the EPUB formats. All the novel editors my wife has worked with need a .docx or .doc format. And for the books we publish ourselves we need to simplify my script when transforming into EPUB or Kindle formats.

EPUB may be problematic. As for .docx, don’t printshops accept PDF? If so, run Writer according to its “native” styling procedure. It is extremely reliable and versatile (you can change layout and formatting in a treat to accommodate various publishing media). See for example my answer here In book publishing, how best to change the page size for a new edition? - #5 by ajlittoz.

«EPUB may be problematic» but necessary these days to obtain a .mobi version. BTW what kind of problems did you encounter?
We use PDF for printshops and initial contact with publishers like Les Escales. But once the contract is signed, there are a lot of interactions between the novelist and the editor. It’s much easier, when not mandatory, to use a common format for round trips like LO - MS Word - LO again.
BTW we use templates intensively, but I will further investigate the notion of master document as indicated in your link. This seems really interesting!

This kind of roundtrip will never return your document unchanged. Progressively, its structure will be damaged beyond repair. You end up with a direct formatted document made of individual pages. All benefits of styles vanish: instead of a concise collection of styles, the conversion process creates zillions of single-use character, list and page styles in addition to direct formatting. Only character styles are more or less kept.

I don’t remember exactly. They were in autonumbering, cross-references and TOC/Index areas. Probably because these features don’t exist natively in EPUB specification.