Prevent Writer from Hiding Text Selection when Switching to Another LibreOffice Window

Title says it all. When I select text (clicking left mouse button, holding it and dragging it over the text), the text is highlighted/selected correctly. But as soon as the Writer window loses focus when switching to another LibreOffice window the selection is no longer visible.

When I select something in Calc and then switch to another Calc window or a Writer window, the selection in Calc is not removed, how I prefer it. (The selection is just a little less detailed, with the small filled box being removed, but that’s fine)

When I select something in Writer and then switch to a non-LibreOffice window (like my webbrowser) the selection in Writer will not be hidden, how I’d like it to be when switching between multiple Writer instances.

Only when I select something in Writer and then switch to another LibreOffice window, will the selection become hidden. After switching from another LibreOffice window back to the main window will the selection become visible again (unless I tap my cursor right in the middle of the text, which I guess LibreOffice interprets as selecting a different part of the text, therefore removing my original selection completly)

How can I make Writer not hide the selection when switching to another LibreOffice window?

I got tasked with merging the text from 5 different documents into one single document and text selection retention would immensely help me with this task. My current workaround is to open one document in OpenOffice, but OpenOffice has the same problem so this doesn’t work with all 5 of the documents at the same time.

Thanks in advance for helping me with this :grinning:

This selection or any other highlighting hiding is usually controlled by the window manager which is a component of the OS (which one?). I kind of remember it is also required by the UI guidelines (de facto standard).

I am using LibreOffice on Windows (10).

I do not care about UI guidelines, I want the app to be usable and aid me in my writing process. I bet there is a way to reconfigure it :wink:

If this really is controlled by the window manager, that doesn’t explain why text selection retention sometimes work, for example when switching to my non-LibreOffice browser, or when switching from Calc to Writer. :thinking:

Workaround

Open the file in which you want to merge everything.
Select ā€˜Insert > Text from file’ in the menu.
Repeat this until everything has been inserted.
Done.

I mean… that could work for other people, unfortunatly it isn’t as simple for me.

The text in my documents are about the same stuff but phrased differently and in a different order. All 5 of the documents are around 60 pages in length.

If I were to just insert the text from every document into the same document right after each other, I’d not have a new text that contains the contents and ideas of the other 5 documents, I’d just have a big document with 5 smaller documents in length.

For me it’s a lengthy process about figuring out where something is written in one document, comparing it to the text written in another document and then rephrasing it into new text. Unfortunatly, it is hard for me to remember where the phrase or sentence was in another document, which keeps me busy finding it again before writing my new sentence. (The selection retention would speed this process up.)

Thanks for the idea tho :smile:

I suggest another workaround. Before switching to another window, mark the current selection with a color - change the font or background color.
image

When you return to the window and see that the selection has been reset, run this macro

Option Explicit 

Sub selectSimilar
Dim oCurrentController As Variant
Dim oViewCursor As Variant
Dim nCharBackColor As Long
Dim nCharColor As Long
Dim Result As Boolean 
	oCurrentController = ThisComponent.getCurrentController()
	oViewCursor = oCurrentController.getViewCursor()
	nCharBackColor = oViewCursor.CharBackColor
	nCharColor = oViewCursor.CharColor
	Result = True
	Do While (oViewCursor.CharBackColor = nCharBackColor) And _
					(oViewCursor.CharColor = nCharColor) And Result
		Result = oViewCursor.goLeft(1, False)
	Loop
	Result = True
	oViewCursor.goRight(1, True)
	Do While (oViewCursor.CharBackColor = nCharBackColor) And _
					(oViewCursor.CharColor = nCharColor) And Result
		Result = oViewCursor.goRight(1, True)
	Loop
	If Result Then oViewCursor.goLeft(1, True)
End Sub

This code simply takes the font and background color at the cursor position, moves left while the colors are the same, and then moves right, highlighting everything along the way. Please note that the colors are taken from the character immediately before the cursor. In other words, if the cursor is positioned before the first character of the filled text, the wrong fragment will be selected.
I’m sure my colleagues will be able to suggest more efficient code that will do this job quickly and without annoying blinking - I just quickly sketched out an idea, not a finished implementation.
To quickly call the macro, you can assign it a hotkey and/or add a command to the context menu - how to do this has been described more than once on this resource.
Of course, after copying and pasting into the resulting document, this fragment will have the colors assigned to it. This can be considered a disadvantage of the proposed approach, but you can look at it from the other side. If you use a separate color for each of the five documents, then in the resulting document you will be able to immediately understand from which source the quote is taken. And getting rid of unnecessary design is very simple - select all the text and simply set the background color to ā€œNo Fillā€ and the font color to ā€œAutomaticā€.

2 Likes

Maybe with a colored character style, that can be assigned to a shortcut keys, and Undo to revert (or another shortcut keys to se No Character Style).

1 Like

I can’t reproduce this problem.
I have several windows open with text documents and spreadsheets. All selected areas are preserved when changing windows.

Version: 25.2.3.2 (X86_64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 6; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Raster; VCL: win
Locale: ru-RU (ru_RU); UI: ru-RU
Calc: CL threaded

A corrupted user profile can cause very strange errors.
See help topic "LibreOffice Installation > Safe Mode".

I did not notice I could copy out information about the build I am using. I hope this is useful.

Version: 25.2.3.2 (X86_64) / LibreOffice Community
Build ID: bbb074479178df812d175f709636b368952c2ce3
CPU threads: 6; OS: Windows 10 X86_64 (10.0 build 19045); UI render: Skia/Vulkan; VCL: win
Locale: de-DE (de_DE); UI: en-US
Calc: CL threaded

I actually thought of highlighting the text I am currently working with by changing the background color, as suggested by @JohnSUN . However, I felt it was slowing me down too much as well, because I am already changing the background color of the texts to ā€œcross outā€ the chapters and paragraphs I’ve already worked on. Considering one can use custom macros and keybindings, I believe I might be able to craft something where I can quickly switch between different highlight colors (which I did not think of until reading Johns post).

I should add, that the selection reappears, when I switch from another LibreOffice window back to the one where I made the selection. I am going to edit my original post with that additional information.

I am also going to wait before I select any suggestion as ā€œa solutionā€, because those are just workarounds. Thank you none the less for your time! :grinning: