[Solved] Wrong focus after double click sheet event

Creating a macro - Writing a Script - Using the API

[Solved] Wrong focus after double click sheet event

Postby JulianR » Fri Dec 07, 2018 11:47 am

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 38 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
JulianR
 
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am

Re: Wrong focus after double click sheet event

Postby mikele » Fri Dec 07, 2018 4:17 pm

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   Expand viewCollapse view
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 on LinuxMint/WinXP/Win7
mikele
 
Posts: 59
Joined: Wed Nov 21, 2018 11:11 am
Location: Germany

Re: Wrong focus after double click sheet event

Postby Lupp » Fri Dec 07, 2018 7:18 pm

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 7.0 and older versions, PortableOpenOffice 4.1.7 and older, StarOffice 5.2
---
Lupp from München
User avatar
Lupp
Volunteer
 
Posts: 2897
Joined: Sat May 31, 2014 7:05 pm
Location: München, Germany

Re: Wrong focus after double click sheet event

Postby JulianR » Mon Dec 10, 2018 9:31 am

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
JulianR
 
Posts: 26
Joined: Mon Mar 12, 2018 9:41 am


Return to Macros and UNO API

Who is online

Users browsing this forum: No registered users and 4 guests