Why ' oDialog.setVisible(True)
is not necessary ?
And why does oDialog.Execute()
work instead ?
Why ' oDialog.setVisible(True)
is not necessary ?
And why does oDialog.Execute()
work instead ?
Hello,
The answer is - Because it is already a part of the Execute function.
But of course this raises other questions like what is it used for? A general understanding of dialogs is needed.
There are two methods to create a dialog - runtime (all code) and graphically (through the Basic IDE).
There is also the characteristic of a dialog to be ‘modal’ (cannot access parent until closed) or ‘non-modal’ (parent is desktop). Each are present in LO and depends upon the need. With ‘modal’ there is no ability to do something with the document until the dialog is closed. With ‘non-modal’ you can do something with the document (example: selecting cells) without the dialog being closed. This is helpful when the dialog relies upon a selection made on the document.
With that background, the ‘setVisible’ function is helpful in creaing a ‘non-modal’ dialog when it was designed through the IDE (graphically). For a brief discussion on this, see the comments in the answer on this post: How to create a modeless ( non modal) dialog. Also note the link in my final comment there.
For a runtime dialog, see the sample posted in my question here: Looking to create grid (not table) control on Base form
Also should mention that your sample is missing a couple of elements. After the Execute statement you should have a oDialog.dispose()
line to free up the resource. Also your dialog has no button assigned as OK
. This would close (end execution) the dialog.
Edit:
One more note of importance, with ‘setVisible’ the next statement in the sub is executed immediately. With the ‘Execute’ statement the next statement will not execute until the dialog is closed.