Hi,
I guess there must be ways to programatically (as opposed to using the Basic IDE) query and / or update macro names of event actions for dialog controls. But the closest I can get is the Events property of the various UnoControl....Model types, for which the ElementNames sub-property lists the events being acted upon, but not the macro names called.
Thanks in advance for your help!
Jesper B.
[Solved] Query and update event actions
[Solved] Query and update event actions
Last edited by JesperBr on Wed Apr 29, 2015 1:54 am, edited 1 time in total.
Open Office 4.1.7
Windows 10
Windows 10
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: Query and update event actions
Hi,
Why do you need this ? What is your real problem ?
Why do you need this ? What is your real problem ?
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: Query and update event actions
Hi B.,
The idea is to create a dialog with several tabs, which I do not think is possible in the IDE (and even if it was possible it would probably be a mess), so instead I use the IDE to create several dialogs. At runtime I load the seperate dialogs and merge them into a programatically created, tabbed, dialog. This seems to work well so far, except for event actions. So I need to programmatically copy event actions from the IDE created controls to those contained in the dynamically created dialog.
Best regards
Jesper
The idea is to create a dialog with several tabs, which I do not think is possible in the IDE (and even if it was possible it would probably be a mess), so instead I use the IDE to create several dialogs. At runtime I load the seperate dialogs and merge them into a programatically created, tabbed, dialog. This seems to work well so far, except for event actions. So I need to programmatically copy event actions from the IDE created controls to those contained in the dynamically created dialog.
Best regards
Jesper
Open Office 4.1.7
Windows 10
Windows 10
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: Query and update event actions
The simplest method in OpenOffice is to use a multi-page dialog. It is fully supported by the IDE. There is no tab but you can display different combinations of controls on the same dialog, just by setting in the IDE the Step property of the dialog model and of each control model.
You change the step of the dialog at runtime, usually when the user clicks a button. The principle is that only controls having the same step value as the dialog are displayed. Exception: controls with Step=0 are always displayed.
Usage is not limited to creating step-by-step wizards; for example Xray uses multi-page dialogs.
OpenOffice can create tabbed dialogs using service UnoControlTabPageContainerModel. But this is not supported by the dialog page of the IDE. You will have to populate the dialog at runtime : add each tab page, add a listener for the tab clicks, add each control in each page, add listeners for each event of each control that uses an event.
An example in Java here, but Basic programming is also possible.
You change the step of the dialog at runtime, usually when the user clicks a button. The principle is that only controls having the same step value as the dialog are displayed. Exception: controls with Step=0 are always displayed.
Usage is not limited to creating step-by-step wizards; for example Xray uses multi-page dialogs.
OpenOffice can create tabbed dialogs using service UnoControlTabPageContainerModel. But this is not supported by the dialog page of the IDE. You will have to populate the dialog at runtime : add each tab page, add a listener for the tab clicks, add each control in each page, add listeners for each event of each control that uses an event.
An example in Java here, but Basic programming is also possible.
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: Query and update event actions
Hello Bernard,
I am aware of the multi-page dialog, but I lean towards the tabbed dialog because 1) I think it suits my application better, and 2) I think creating a multi-page dialog in the IDE would be a mess, unless each page contains very few control elements.
I already have a working tabbed dialog (based on this example: https://issues.apache.org/ooo/attachment.cgi?id=76104), but the problem is, how do I add event actions to the controls?
To illustrate what I would like to do, I have created a simple Writer document, with a few dialogs and macros:
The macroes in modules ExecSimple1 and ExecSimple2 execute dialogs Simple1 and Simple2 respectively. The text fields in the two dialogs have an action defined for the KeyPressed event - a message box will appear if a key is pressed.
The macro in module ExecTabbed merges the two simple dialogs into one tabbed dialog, but the action event does not work here - which is what I really want it to do. So the question is, how can I copy the event action definition from the original dialog or control to the new one? Or alternatively, is it possible to add a hard-coded event action definition to a dynamically created dialog or control?
Regards
Jesper
I am aware of the multi-page dialog, but I lean towards the tabbed dialog because 1) I think it suits my application better, and 2) I think creating a multi-page dialog in the IDE would be a mess, unless each page contains very few control elements.
I already have a working tabbed dialog (based on this example: https://issues.apache.org/ooo/attachment.cgi?id=76104), but the problem is, how do I add event actions to the controls?
To illustrate what I would like to do, I have created a simple Writer document, with a few dialogs and macros:
The macroes in modules ExecSimple1 and ExecSimple2 execute dialogs Simple1 and Simple2 respectively. The text fields in the two dialogs have an action defined for the KeyPressed event - a message box will appear if a key is pressed.
The macro in module ExecTabbed merges the two simple dialogs into one tabbed dialog, but the action event does not work here - which is what I really want it to do. So the question is, how can I copy the event action definition from the original dialog or control to the new one? Or alternatively, is it possible to add a hard-coded event action definition to a dynamically created dialog or control?
Regards
Jesper
Open Office 4.1.7
Windows 10
Windows 10
-
- Volunteer
- Posts: 1160
- Joined: Mon Oct 08, 2007 1:26 am
- Location: France, Paris area
Re: Query and update event actions
I tested your unusual method in a simpler case : copy the controls of Simple1 into an empty Dialog1. I can see the controls but the events are not handled (although the control models have Events property filled).
So your simple method just does not work for events.
I don't know how to "copy" the event configuration, perhaps it is not possible from the API.
The API method is to add (and later remove) the appropriate listener for each of your controls.
That's a lot of tedious work.
So your simple method just does not work for events.
I don't know how to "copy" the event configuration, perhaps it is not possible from the API.
The API method is to add (and later remove) the appropriate listener for each of your controls.
That's a lot of tedious work.
Bernard
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
OpenOffice.org 1.1.5 / Apache OpenOffice 4.1.1 / LibreOffice 5.0.5
MS-Windows 7 Home SP1
Re: Query and update event actions
I do not mind to "add (and later remove) the appropriate listener for each of your controls" as long as it can be done programatically - and I have actually made it work.
Since I cannot figure out how to query listeners in the source dialogs' controls I changed the approach a little: For those controls that need a key listener I added the text "KeyListener" in the "Additional information" field of the Properties dialog. At runtime this text appears in the ControlModel's Tag property, so I test for the text and add a key listener to the control object if required.
It took me a while to figure out how to access the controls to which the listener should be added, but this does the trick:
I am not sure it interests anybody, but here is the working version of my demo:
And by the way, thank you Bernard, for providing your thoughts!
Since I cannot figure out how to query listeners in the source dialogs' controls I changed the approach a little: For those controls that need a key listener I added the text "KeyListener" in the "Additional information" field of the Properties dialog. At runtime this text appears in the ControlModel's Tag property, so I test for the text and add a key listener to the control object if required.
It took me a while to figure out how to access the controls to which the listener should be added, but this does the trick:
Code: Select all
dim i%, j%, k%, l%
for i = 0 to uBound (dialog.TabControllers)
dim TabController : TabController = dialog.TabControllers (i)
for j = 0 to uBound (TabController.Controls)
dim TabPageContainer : TabPageContainer = TabController.Controls (j)
for k = 0 to uBound (TabPageContainer.Controls)
dim TabPage : TabPage = TabPageContainer.Controls (k)
for l = 0 to uBound (TabPage.Controls)
dim BaseControl : BaseControl = TabPage.Controls (l)
if inStr (BaseControl.model.Tag, "KeyListener") then AddKeyListener (BaseControl)
if inStr (BaseControl.model.Tag, "MouseListener") then AddMouseListener (BaseControl)
next l
next k
next j
next i
Open Office 4.1.7
Windows 10
Windows 10