[Solved] Wrong focus after double click sheet event

Creating a macro - Writing a Script - Using the API (OpenOffice Basic, Python, BeanShell, JavaScript)
Post Reply
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

[Solved] Wrong focus after double click sheet event

Post by JulianR »

Hi!

I am looking for a workaround to a weird problem (I think it is a bug, but maybe I just can't find the proper way to do what I am doing).
If I open a dialog window with a sheet double click event, after I close the dialog, the focus is set to spreadsheet grid (I need to click on any cell, to regain normal window focus). If I click, say on a toolbar, or a button placed on top the sheet, the program will recognize mi as clicking on a cell underneath (and in case I clicked outside the main window, say on taskbar, the spreadsheet will jump to a cell, that would be where I clicked, if the grid was visible there).

See the attached file, double click anywhere on sheet1, close the dialog and try clicking on sheet2 or on the button to call the dialog again, and you will see, what I mean.

I have tried setting focus manually on the main window, button on the form before ending the code handling the event, but to no avail.

Any ideas how to get around this?
Attachments
Test Wrong Focus.ods
(10.3 KiB) Downloaded 106 times
Last edited by JulianR on Mon Dec 10, 2018 9:32 am, edited 1 time in total.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
mikele
Posts: 72
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: Wrong focus after double click sheet event

Post by mikele »

Hello,
it's not a bug but a strange behavier.
Declare the sub as boolean and set it "true" at the end.

Code: Select all

Sub Main (oevent) as boolean
MsgBox "Check window focus after closing me"
main =true
End Sub
By the way: with the parameter oevent you'll access e.g. to the cell you clicked on.
LibreOffice 5.4, 7.0, 7.2 on LinuxMint/Win10
User avatar
Lupp
Volunteer
Posts: 3553
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Wrong focus after double click sheet event

Post by Lupp »

Andrew Pitoyak; Useful Macro Information... wrote:14.3.6. Example 3: com.sun.star.awt.XKeyHandler
Handlers are a special type of listener. As listeners they can intercept an event, but in addition
an handler acts as event consumer, in other words, an handler can “eat” the event. In
difference to listeners, methods in handlers must get a result (boolean): a True result tells to
broadcaster that the event is consumed from the handler, this causes that broadcaster will not
send the event to the rest of the handlers.
Not to propagate the event to a default handler may be dangerous if you don't know what the default handler is suppused to complete.
On Windows 10: LibreOffice 24.2 (new numbering) and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
JulianR
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: Wrong focus after double click sheet event

Post by JulianR »

Thanks guys. It works properly now. Something to remind me, that I should read docs with greater attention to detail.
Apache OpenOffice 4.1.1 / LibreOffice 5.3 / LibreOffice 6.0 / LibreOffice 6.2 on Windows 7
Post Reply