Apache OpenOffice (AOO) Bugzilla – Issue 52459
API: Mutliple calls to assigned event handler for sub-form controls
Last modified: 2017-05-20 10:48:04 UTC
This behavior only happens when the form is created from within a database document. It does not happen if the form is created directly from writer. I have a form document with some contols on it and I want to have a macro run when the user double clicks in one of the controls. I can create a macro such as In my case at hand it is a grid and I want the user to be able to "drill down" to a pop form with detail information about the specific row entry. Code: sub catchclick( oEv as Object ) if oEv.ClickCount > 1 then print "hello" endif end sub I assign this macro to the "Mouse Button Released" event of a control. Now at this point everything happens as I would expect. I get a message box only when I double click in the specific control. However, I add a sub-form to my form document and purt some controls on the form document from the sub-form. Now if I assign the macro to the "Mouse Button Released" event of one of these controls, then the macro is called once for every control at the main form level and once for the control at the sub-form level. Every call to the macro carries, as best as I can tell, the exact same source object.
Do you mind attaching a small sample database for easier reproduction?
Created attachment 28646 [details] example files
I am attaching a database file and a macro library that demonstate the problem. The database is named schooldays.odb and the library files are for a library named dbutil. In the database the form named COURSES will call the catchDblClick macro in the library when you double click on the Student grid. Double click on a cell in the grid and you will get the message box 9 times, one for every control on the mainform and once for the grid.
thanks for this wonderful sample document! Confirming, targeting, assigning.
I think this related to this issue, if not I can always open another. In working with 2.0.2 I have found a difference between the events Before Record Change and After Recrod change. Attached is another small test database, one table and one form. The form has the Before Record Change and After Record Change events of the main dataform control assigned to the follwoing sub procedures. ( if you create a new library and name it Tasker the links will be fine, if you copy this into a different library then of course you must change the forms defintion) sub onBeforeRecordChange( oEvent as variant ) print "Before Record Change" print oEvent.Source.ImplementationName end sub sub onAfterRecordChange( oEvent as variant ) print "After Record Change" print oEvent.Source.ImplementationName end sub When Form1 is opened each of these procedures is called once, and each with a source object of type com.sun.star.comp.forms.ODatabaseForm. When you move to the second record however the difference arises. The procedure onBeforeRecordChange will be called twice, the first time with a source object of type com.sun.star.form.FmXFormController and the second time with com.sun.star.comp.forms.ODatabaseForm. The onAfterRecordChange procedure is called only once, with the source object of type ODatabaseForm. I assume the later is correct and the former an error.
Created attachment 35082 [details] Date base showing event calls
adjusting summary so that we'll find it in the big "fix as much API bugs as possible" sweep :)
Created attachment 37429 [details] ODB file created under RC7
Reset assigne to the default "issues@openoffice.apache.org".