[Solved] Non-modal Dialog
-
- Posts: 30
- Joined: Wed Jan 27, 2016 6:43 pm
[Solved] Non-modal Dialog
Most links here do not appear to work to threads about this - PHP script broken.
I wish to have a Dialog which is non-modal to allow scrolling of a spreadsheet behind.
I wish to have a Dialog which is non-modal to allow scrolling of a spreadsheet behind.
Last edited by mikephillips on Sat Jan 30, 2016 4:59 pm, edited 1 time in total.
Open Office 4.0.1 on Windows 7
Re: Non-modal Dialog
I had the attached file lying around with a very simple example.
- Attachments
-
- Non-modal dialog.ods
- (14.92 KiB) Downloaded 493 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 30
- Joined: Wed Jan 27, 2016 6:43 pm
Re: Non-modal Dialog
Hmm! Thanks for digging that out, FJCC, but I am out of my depth here. I see a Command button on the sheet which initially opens Xray and when that is closed a non-modal Dialog1 (good - just what I want!). Could you please explain (very patiently) to me where is the code to open Dialog1 and what makes it non-modal? The sheet is opening 'Read Only' for me so I cannot examine it.
Open Office 4.0.1 on Windows 7
Re: Non-modal Dialog
I changed the code so there is a variable called Modal. If it is true, The dialog will come up but you can't interact with the spreadsheet and the dialog as it exists is useless. If you set Modal to False, you can click on the sheet and change the content of the text box in the dialog. Note that in the Modal version, the dialog is closed with the OK button and in the non-modal version you have to click on the radio button. The Do loop in the code is watching the state of the radio button. Of course, you normally make a dialog for only one of these situations.
- Attachments
-
- Non-modal dialog.ods
- (20.27 KiB) Downloaded 535 times
OpenOffice 4.1 on Windows 10 and Linux Mint
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
-
- Posts: 30
- Joined: Wed Jan 27, 2016 6:43 pm
-
- Posts: 30
- Joined: Wed Jan 27, 2016 6:43 pm
Re: Non-modal Dialog
For those, like me - beginners - who do not want the 'Mickey Mouse' soultions sometimes offered (and with thanks to FJCC) this is the simple code I am using to produce a non-Modal dialogue (d1) over my Calc sheet. '
Incredibly simple but VERY difficult to track down, and it should not be! A non-modal option should be a 'bread and butter' requirement for any GUI with dialogues. I am amazed it does not exist in OO. NB I have not bothered with an 'exit' from the non-modal loop since I have a 'Close Programme 'option on d1 anyway for when I no longer need the other functions on it.
Code: Select all
d1.visible = true
do
wait (100)
loop
Open Office 4.0.1 on Windows 7
Re: [Solved] Non-modal Dialog
Resurrecting this old thread in case anyone new looks for this.
This is how to do this without a Wait timer:
This is how to do this without a Wait timer:
Code: Select all
'your library with this code has to be in MyMacros not in the document or the URI will give an error.
Sub Test
oParent = ThisComponent.getCurrentController().getFrame().getContainerWindow()
dlg = CreateNonModalDialog(oparent,"JeTest.Dialog1",true) 'example library called JeTest and Dialog called Dialog1
dlg.setpossize 100,100,500,500,15
dlg.setvisible true
End Sub
Function CreateNonModalDialog(oParent,DialogParam, Closeable as boolean) As Variant
dim dlg,CWP,sURL As String
sURL = "vnd.sun.star.script:" & DialogParam & "?location=" & "application"
CWP = CreateUnoService("com.sun.star.awt.ContainerWindowProvider")
dlg = CWP.createContainerWindow(sURL, "", oParent, nothing)
if Closeable then 'if want closeable need this
dlg.addTopWindowListener(CreateUnoListener("NonModalWindowListener_", "com.sun.star.awt.XTopWindowListener"))
end if
CreateNonModalDialog = dlg
End Function
'XTopWindowListener subs
Sub NonModalWindowListener_disposing(ev)
End Sub
Sub NonModalWindowListener_windowOpened(ev)
End Sub
Sub NonModalWindowListener_windowClosing(ev)
ev.source.dispose 'if want closeable need this
End Sub
Sub NonModalWindowListener_windowClosed(ev)
End Sub
Sub NonModalWindowListener_windowMinimized(ev)
End Sub
Sub NonModalWindowListener_windowNormalized(ev)
End Sub
Sub NonModalWindowListener_windowActivated(ev)
End Sub
Sub NonModalWindowListener_windowDeactivated(ev)
End Sub
'/XTopWindowListener subs
sub commandclose(ev) 'if window is not closeable you might want a button perhaps to close it
ev.source.context.dispose
end sub
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
-
- Posts: 30
- Joined: Wed Jan 27, 2016 6:43 pm
Re: [Solved] Non-modal Dialog
Jeje - many thanks for resurrecting my query. I will look with interest at your solution.
Open Office 4.0.1 on Windows 7
Re: [Solved] Non-modal Dialog
Very interesting, indeed. In order to make this work with non-document windows such as the IDE or the welcome screen:
This is a good example how the total lack of documentation inhibits thousands of interested coders.
The xHandler argument is the next interesting argument.
Code: Select all
oParent = StarDesktop.getCurrentFrame().getContainerWindow()
Today I've learned that "the URL" is meant to be a dialog's script-URL, finally after 20 years.Documentation on createContainerWindow wrote:Methods' Summary
createContainerWindow creates a window for the given URL
Methods' Details
createContainerWindow( [in] string URL,
[in] string WindowType,
[in] XWindowPeer xParent,
[in] ::com::sun::uno::XInterface xHandler )
raises( ::com::sun::lang::IllegalArgumentException );
Description
creates a window for the given URL
Parameter URL
is the URL.
The xHandler argument is the next interesting argument.
Please, edit this topic's initial post and add "[Solved]" to the subject line if your problem has been solved.
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Ubuntu 18.04 with LibreOffice 6.0, latest OpenOffice and LibreOffice
Re: [Solved] Non-modal Dialog
My code above is based on part of the code (the 'inner' dialog) from the resizable dialog thread which was originally work by hanya.
viewtopic.php?f=21&t=92867
You can create a resizable dialog with that code - which is fine with a modal dialog, but I found there's a crash if the document window is closed before the dialog is if its non-modal.
viewtopic.php?f=21&t=92867
You can create a resizable dialog with that code - which is fine with a modal dialog, but I found there's a crash if the document window is closed before the dialog is if its non-modal.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)
Re: [Solved] Non-modal Dialog
You can use another dialog (modal or non-modal) as the oParent with oParent = Dialog.getPeer (but the new dialog must have with title bar set to yes, which is the default value, or there will be a crash)
Edit: indeed generally using this method to try to create a dialog with title bar changed to no causes a crash. Not a problem, just a note that that can't be done.
Edit: indeed generally using this method to try to create a dialog with title bar changed to no causes a crash. Not a problem, just a note that that can't be done.
Windows 10, Openoffice 4.1.11, LibreOffice 7.4.0.3 (x64)