Pinning the prompt to a certain height on the display. Is it possible?

Hi all,

is it possible to pin the prompt to a specific height on the display when writing a text in writer?
When I write long texts, I always end up quickly on the bottom line of the display.

I would rather like to have the prompt centered. My neck would greatly benefit from this :wink:

Best regards,
DoCa

AFAIK there isnā€™t.

There is a setting View > Web which just shows text without page breaks or margins which might be helpful. If this is set and the window is set to half height, to go from top to halfway down then you will eventually end up typing on the last row which will be the middle of the screen.

1 Like

Thank you for the tip. After writing the question, I thought of sizing the window myself.

However, with that solution, I only see a smaller part of the document.

Anyway, I will use that as a solution.

Best regards,
DoCa

I guess you work on a laptop. Depending on your equipment, you could try with an external monitor. I bought a cradle onto which I attached my screens. I adjusted the arms so that monitors are at eye-height. If your screens are relatively small (I donā€™t consider 1920Ɨ1080 as vertically ā€œsmallā€), you can even rotate them 90Ā° (portrait orientation) and tell the OS so that video signal is modified accordingly. This might be more comfortable for office work, though luminosity may not be as good (because of the angle of vision with LCD and their polarizers).

I have a similar problem. I edit existing documents many pages long and I need to see a couple of paragraphs ahead. During editing I frequently end up at the bottom of the screen. I sort of solved mine with the following hack.

At regular intervals I insert a code to my document using a macro. When the macro fires to insert the code into the text, it runs the following code,

sub scrollViewUp()

 	Dim oDoc: oDoc = ThisComponent
	
	Dim oVCurs, oTCurs
	oVCurs = oDoc.currentController.getViewCursor()

	'Save the position
	oTCurs = oDoc.Text.createTextCursorByRange(oVCurs)
	
	oVCurs.screenDown()

	'In case VC off the screen
	oVCurs.gotoRange(oTCurs,false)
	
	'Make cursor visible
	oDoc.currentcontroller.select(oVCurs)

end sub

The end result is that the current position of the cursor/view is shifted to the top of the window. This works only while there is text off screen below.

If the position is too high/low, you can use the following to adjust up or down,


'
'	i takes accepts following values
'		0 - scrolls up 1 line
'		1 - scrolls down 1 line
'		2 - scrolls up a screen full
'		3 - scrolls down a screen full
'
sub doscrollEvent(i)
	dim found as boolean
	
	found = false
	
	dim comp,compchild
	
	comp = thiscomponent.currentcontroller.frame.getcomponentwindow
	compchild = comp.getAccessibleContext.getAccessibleChild(0)
	
	on error resume next
	
	dim j
	for j = 0 to compchild.getAccessibleContext.getAccessibleChildcount -1
	   with compchild.getAccessibleContext.getAccessibleChild(j)
	      if .getAccessibleContext.getAccessibleName = "Vertical scroll bar" then found = true
	      if found then
	         .getAccessibleContext.doAccessibleAction(i)
	         exit for
	      end if
	   end with
	next
end sub

I am currently looking to use an event listener to have this run automatically even if I dont run my macro but I havenā€™t figured that part yetā€¦ Iā€™ll update when/if I do.

HTH

Hi CaveMan,

that sound great. Let us know, if you find a way of calling your script automatically.

Thanks

So here is the complete code that I have been using for a few days now and seems stable. It uses a listener to trigger the adjustment to the view whenever any key is pressed. In this post I am using a different method to center the cursor than the code above. This code seems to be more efficient.

Things to note:

  1. Once you start the listener by running StartXKeyHandler, you can stop it by running StopXKeyHandler AS LONG as you dont edit the code. Doing so will cause the code to be recompiled and any stored reference to the listener will be lost. Only way to stop it then is to close and reopen the document.

  2. If you dont want it to fire at every keypress, maybe your system is slow, you can uncomment the code around VCToCentreScreen and use the key constants to choose the keys it will be actioned upon.

  3. The listener get registered on the active document. This means you need to re-run StartXKeyHandler for every document you want the cursor to be centered. And because the code checks the global variable, that bit of code will need to go or change it to store multiple objects.

HTH


Global oXKeyHandler

'Key codes from 
' https://www.openoffice.org/api/docs/common/ref/com/sun/star/awt/Key.html
const K_BACKSPACE = 1283
const K_SPACE = 1284
const K_DELETE = 1286
const K_RETURN = 1280


Sub StartXKeyHandler()
    If IsNull(oXKeyHandler) or isEmpty(oXKeyHandler) Then
        oXKeyHandler = CreateUnoListener("XKeyHandler_", "com.sun.star.awt.XKeyHandler")
        ThisComponent.GetCurrentController.AddKeyHandler(oXKeyHandler)
        print "Key handler activated."
	else
		print "Key Handler already active!"
    End If
End Sub

Sub StopXKeyHandler()
    If Not ( IsNull(oXKeyHandler) or IsEmpty(oXKeyHandler) ) Then
        ThisComponent.GetCurrentController.removeKeyHandler(oXKeyHandler)
        oXKeyHandler = Nothing
        print "Key handler has been DEACTIVATED."
	else
		print "Key handler is NOT active at the moment."
    End If
End Sub


Sub XKeyHandler_disposing(oEvent)
    Call StopXKeyHandler
End Sub


Function XKeyHandler_keyPressed(oEvent) As Boolean
    XKeyHandler_keyPressed = False  'Don't cancel thisā€¼

	dim vCode, p
    vCode = oEvent.KeyCode
	   
'	    select case vCode 
'	    	case K_SPACE, K_BACKSPACE, K_RETURN:
	    		VCToCentreScreen
'	    end select

End Function

Function XKeyHandler_keyReleased(oEvent) As Boolean
    XKeyHandler_keyReleased = False  'Don't cancel thisā€¼
End Function


'
' From https://forum.openoffice.org//en/forum/viewtopic.php?f=20&p=495197
'
'I don't have the exact answer
'this roughly works on mine with the zoom at 100%
'you can play around with one or other someothervalue to try and get
'something better/more general in these two lines
'   svalue = (y+someothervalue)/ (10/(2.83465 * 2))
'   svalue = svalue - someothervalue
sub VCToCentreScreen
   Dim doc: doc = thiscomponent
   Dim vc: vc =doc.currentcontroller.viewcursor
   Dim y: y= vc.position.y 'position is in page/metric coordinates
   
   Dim svalue
   'svalue = (y+someothervalue )/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   svalue = (y+0)/ (10/(2.83465 * 2)) 'converts value to scrollbar uses half points
   
   Dim comp
   comp =doc.currentcontroller.frame.getcomponentwindow
   
   Dim compchild
   compchild=comp.getAccessibleContext.getAccessibleChild(0)
   
   Dim j
   for j = 0 to compchild.getAccessibleContext.getAccessibleChildcount -1 'find the scrollbar
      with compchild.getAccessibleContext.getAccessibleChild(j)
         if .getAccessibleContext.getAccessibleName = "Vertical scroll bar" then
         '.getblockincrement is usually the amount scrolled when screen down
         'subtract a bit for that /2 doesn't work on my machine /5 roughly does
            'svalue = svalue - someothervalue
            svalue = svalue - .getblockincrement/5
            .getAccessibleContext.setcurrentvalue clng(svalue)
            exit for
         end if
      end with
   next
end sub
1 Like

Hi CaveMan,

that is great!

I will give it a try a soon as I am back in my office.

Thank you!!
DomCa