Bug 114463 - Macro incorrectly run when a space is typed in to a selected cell
Summary: Macro incorrectly run when a space is typed in to a selected cell
Status: RESOLVED NOTABUG
Alias: None
Product: LibreOffice
Classification: Unclassified
Component: Calc (show other bugs)
Version:
(earliest affected)
5.4.3.2 release
Hardware: x86-64 (AMD64) Windows (All)
: medium normal
Assignee: Not Assigned
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2017-12-14 13:49 UTC by roger
Modified: 2018-01-15 17:58 UTC (History)
2 users (show)

See Also:
Crash report or crash signature:


Attachments
Spreadsheet with macro demonstrating problem (15.17 KB, application/vnd.oasis.opendocument.spreadsheet)
2017-12-14 13:49 UTC, roger
Details
button properties (57.27 KB, image/png)
2017-12-14 21:44 UTC, raal
Details

Note You need to log in before you can comment on or make changes to this bug.
Description roger 2017-12-14 13:49:55 UTC
Created attachment 138444 [details]
Spreadsheet with macro demonstrating problem

I have a spreadsheet with a button which runs a macro to insert a new row at the bottom of a table.
It then selects a cell in that row.
When a space is typed in to that cell, the macro runs again and adds another row.
This does not occur if before typing I select another cell, then return.
Attached is a file containing a macro, which demonstrates the problem.

This did not occur before I updated to version 5.4.
Comment 1 Xisco Faulí 2017-12-14 14:30:18 UTC
I can also reproduce it in

Versión: 4.4.0.3
Id. de compilación: de093506bcdc5fafd9023ee680b8c60e3e0645d7
Configuración regional: es_ES

In which version did it work for you?
I'm wondering if the macro is correctly programmed...
Comment 2 roger 2017-12-14 15:52:42 UTC
It first appeared in 5.4.2 which I installed on 21 Nov 2017. I do not remember what version I used before that - I do not install every update.

It is a macro I have used for many years, but this does not mean it is correct. I would appreciate any constructive criticism of it.
Comment 3 raal 2017-12-14 21:43:59 UTC
I can reproduce it with LO 3.5.0 . It's not a bug - macro runs because button has a focus and space key act as push the button action. You can disable it  - set Take Focus on click to false.
Comment 4 raal 2017-12-14 21:44:21 UTC
Created attachment 138453 [details]
button properties
Comment 5 roger 2017-12-14 22:57:24 UTC
Thank you for diagnosing this and providing a solution.

I was not aware that spacebar will activate a button with focus and, though I may have missed it, have not been able to find this in any documentation.

However, the fact remains that I have seen a change of behaviour in more than one of my spreadsheets. Perhaps there has been a change in some default property somewhere.

Thank you again.
Comment 6 roger 2018-01-13 19:39:27 UTC
I am afraid I must re-open this.

While setting the control 'Take Focus on Click' to 'No' works immediately, if the sheet is saved, closed, and reopened (or reloaded), it has reverted to 'Yes'.

I also suspect that, while this behaviour may have existed before when the space was the first character in the cell, it did not behave like this for an embedded space between printing characters.
Comment 7 raal 2018-01-13 19:56:13 UTC
(In reply to roger from comment #6)
> I am afraid I must re-open this.
> 
> While setting the control 'Take Focus on Click' to 'No' works immediately,
> if the sheet is saved, closed, and reopened (or reloaded), it has reverted
> to 'Yes'.
> 
> I also suspect that, while this behaviour may have existed before when the
> space was the first character in the cell, it did not behave like this for
> an embedded space between printing characters.

Hello, 

 While setting the control 'Take Focus on Click' to 'No' works immediately,
 if the sheet is saved, closed, and reopened (or reloaded), it has reverted
 to 'Yes'.

works for me in Version: 6.1.0.0.alpha0+
Build ID: 88f6ffeb9e0c0b942c2b0bc9d60af7bb7a6caaf8
CPU threads: 4; OS: Linux 4.4; UI render: default; VCL: gtk3; 

Seems to be fixed in dev version. Please could you test with dev version?
http://dev-builds.libreoffice.org/daily/master/
Thank you
Comment 8 roger 2018-01-14 10:43:23 UTC
I have tested this on Dev Version: 6.1.0.0.alpha0+ (x64), downloaded this morning.

The program ran correctly immediately on loading, which implies to me that the 'take focus' flag was being set to 'Yes' when loaded by version 5.4, rather than when being saved.

Since I do not wish to work with a development version, I will have to live with this problem until a new release resolves it.

Thanks for your assistance.
Comment 9 roger 2018-01-15 17:58:53 UTC
I have made a work-around for this problem, until such time as it is resolved in an update. This may be of interest to others.

I have set the following macro to run when my file is opened:

Sub adjustButton
Dim Sheet As Object
Dim Doc as object
Dim Form As Object
Dim ctl As Object 
	Doc = ThisComponent.CurrentController
	Sheet = Doc.activeSheet
	Form = Sheet.DrawPage.Forms.GetByIndex(0)
	Ctl = Form.getByName("New Entry")
	Ctl.FocusOnClick=false

End Sub