| View previous topic :: View next topic |
| Author |
Message |
Aaron General User

Joined: 14 Nov 2003 Posts: 34 Location: Cincinnati, OH
|
Posted: Wed Nov 10, 2004 10:08 am Post subject: Non-Modal Dialogs |
|
|
There has been a good amount of discussion regarding the ability (or lack thereof) to open non-modal (modaless) dialog boxes in OOo. Two of the more active discussions can be found here:
http://www.oooforum.org/forum/viewtopic.php?t=5381
http://www.oooforum.org/forum/viewtopic.php?t=5381
I wanted to reopen this discussion as it seems that no solution was ever found. I am hoping that maybe some fresh eyes on the problem may help. I think the basic goal here is to be able to open a dialog box, but still be able to interact with the windows behind the dialog box without closing it first.
Any ideas?
Thanks,
Aaron |
|
| Back to top |
|
 |
SergeM Super User

Joined: 09 Sep 2003 Posts: 3211 Location: Troyes France
|
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Wed Nov 10, 2004 8:32 pm Post subject: |
|
|
Yes it is possible. There is a AWT Toolkit service that lets you integrate or create new frames. Those frames can be non-modal, modal or something else (the windowdescriptor is the one where you specify that).
Have a look at a simple Starbasic example:
http://www.oooforum.org/forum/viewtopic.php?t=9883
Hope this helps.
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Fri Nov 12, 2004 12:37 am Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 2:03 am; edited 1 time in total |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
Posted: Fri Nov 12, 2004 11:30 am Post subject: |
|
|
There are two different things here. Actually three.
1. Dialogs
2. AWT
3. Forms
Forms are much higher level than the other two.
Of the first two, Dialogs are something using the UnoDialogControl and its model. You can also create AWT windows with controls.
AWT windows are modeless, and are not tied to any other window.
AWT windows are not the same thing as dialogs.
Generally, dialogs are operated modally by calling execute() on the dialog.
I have also had some success operating dialogs modelessly. Just unhide the dialog, and it can be used modelessly. One drawback is that the modeless dialog seems to be tied to some concept of a "parent" window. I'm not sure, but I think that tends to be whatever window was in front when you created the dialog. So for example, you could create a modeless dialog that allows you to work with your document, but that modeless dialog's behavior appears to be tied to that document. Bring the modeless dialog to the front, and its document also comes to the front. _________________ Want to make OOo Drawings like the colored flower design to the left? |
|
| Back to top |
|
 |
Cybb20 Super User


Joined: 02 Mar 2004 Posts: 1569 Location: Frankfurt, Germany
|
Posted: Fri Nov 12, 2004 3:19 pm Post subject: |
|
|
Good that you clarified that. I wasn't sure what was explicitly asked for as well, Aaron might let us know soon .
Christian _________________ - Knowledge is Power - |
|
| Back to top |
|
 |
DannyB Moderator


Joined: 02 Apr 2003 Posts: 3991 Location: Lawrence, Kansas, USA
|
|
| Back to top |
|
 |
Robby OOo Advocate

Joined: 21 Sep 2004 Posts: 249
|
Posted: Sun Nov 14, 2004 1:18 am Post subject: |
|
|
xxx
Last edited by Robby on Sun Dec 11, 2011 2:03 am; edited 1 time in total |
|
| Back to top |
|
 |
stephan_beta General User

Joined: 13 Feb 2007 Posts: 16 Location: Genova, Italy
|
Posted: Tue Mar 06, 2007 1:40 am Post subject: |
|
|
I resume this very old thread to ask someone more expert than me if what I understood is correct on the basis of this following words from DannyB:
| DannyB wrote: | | One drawback is that the modeless dialog seems to be tied to some concept of a "parent" window. I'm not sure, but I think that tends to be whatever window was in front when you created the dialog. So for example, you could create a modeless dialog that allows you to work with your document, but that modeless dialog's behavior appears to be tied to that document. Bring the modeless dialog to the front, and its document also comes to the front. |
Also referencing this thread about non-modal dialog, I wondered "why do I have to create an invisible window to pop up my dialog?".
Now, after some experiments I tend to think that a dialog is always modal no matter what.
What I tried is
| Code: | XWindowPeer xPeer = xToolkit.getDesktopWindow( );
xControl.createPeer( xToolkit, xPeer ); |
instead of
| Code: | XWindowPeer xPeer = xToolkit.createWindow( aDescriptor );
XWindow xWindow = (XWindow)UnoRuntime.queryInterface( XWindow.class, xPeer );
xWindow.setVisible( false );
xControl.createPeer( xToolkit, xPeer ); |
Doing this, the dialog I show is modal with respect for the document window I created the dialog upon. Say, I open OOo, create a new spreadsheet and a new writer document. If I execute my dialog from the spreadsheet window that one will be unaccessible, but the writer one will be not.
Funny thing is that if I do setVisible(true), I will see the blank window and the dialog. I can drag around the window, but until the dialog is open it will keep the focus. If I close the dialog the window will remain and I can't even close it! If I try again and close the dialog I will have 2 open windows, and so on! More, they remain alive even if I close the main OOo instance. On Linux I have to kill them.
Hence, creating "modeless dialog" seems to me more a workaround than a real solution.
Am I correct or am I missing something? |
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Sat Apr 14, 2007 9:38 am Post subject: A modeless dialog |
|
|
Hello,
using the information in the link :
http://www.oooforum.org/forum/viewtopic.phtml?t=9883
we have developped a fully featured non modal dialog. Which means :
A window with all the classic commands (buttons, togle buttons, check boxes, Radio buttons, list, labels. This window remains opened on top of the document and we can do anything in the document, selecting, moving and so on.
The only trouble we have is :
To be easy to use, this dialog must stay on top of the document. We have not find a way to achieve this inside OpenOffice. So we have used a small program, Deskpins, which can automatically pin a window and make it stay on top. In Windows, it works fine, but for Linux another solution must be found.
If anyone knows how to make a window created by the awt toolkit stay on top, I am interested. It is the last issue on this question.
[edited] See the solution of this problem below _________________ Dysmas
Last edited by dysmas on Mon Apr 23, 2007 12:41 am; edited 1 time in total |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Sun Apr 15, 2007 7:12 am Post subject: Re: A modeless dialog |
|
|
| dysmas wrote: | ...The only trouble we have is :
To be easy to use, this dialog must stay on top of the document. We have not find a way to achieve this inside OpenOffice. ... If anyone knows how to make a window created by the awt toolkit stay on top, I am interested. It is the last issue on this question. |
I am not aware of something like an AlwaysOnTop Property of anything in OO. A workaround would be to start a TopWindowListener on the mother document, when your dialog is shown. Whenever the mother document is activated, you can toFront() the dialog window
Good luck,
ms777 |
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Sun Apr 15, 2007 7:40 am Post subject: |
|
|
We have tried this, but it is not a good solution because when you click on the document, the dialog window disappears and then reappears, and when it reappears, since it takes the focus, you loose the control of the document. For example, if you were opening a menu, the menu is closed.
If there is no other workaround, deskpins is a solution, but for windows users only... _________________ Dysmas |
|
| Back to top |
|
 |
ms777 Super User


Joined: 07 Feb 2004 Posts: 1355
|
Posted: Sat Apr 21, 2007 8:55 am Post subject: |
|
|
Hi,
you can make the dialog window stay on top of the document by specifying ThisComponent.CurrentController.Frame.ContainerWindow as parentWindow, when you create the dialog's TopWindow.
I did not find a way to move the dialog with the mother document, though
Good luck,
ms777 |
|
| Back to top |
|
 |
dysmas Power User

Joined: 14 Apr 2007 Posts: 59 Location: Grenoble, France
|
Posted: Mon Apr 23, 2007 1:25 am Post subject: |
|
|
Wonderful, and many thanks it works !
so we have now a working solution for non-modal dialogs with the only trouble that it must be hard-coded.
I wondered if it would be possible to load in our window a dialog built with the GUI IDE. And I discovered a surprising thing : You can have a non-modal dialog by modifying just one line in your code.
Try this :
You have already prepared your (standard) dialog.
You load it by the commands :
dlg = loadDialog ("modaless","Dialog1")
answer = dlg.execute()
OK, this loads the normal modal dialog.
Now change the second line like this :
dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true
AND (very important) either execute your macro step by step or place a break point after these lines. Your dialog opens and IS NOT MODAL !
To close it just continue your macro. When it closes, the dialog disappears.
And this is the problem : if you don't stop the macro, you will not be able to see the dialog.
I have found a dirty workaround :
After the lines above, I added
do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop
And II added a Toggle button in the dialog which name is CloseButton. The name can be different (just have to be the same as in the lines above) but it MUST me a TOGGLE button, otherwise the above code will not work.
Not too complicated, as you see. And now you can build your dialog with the GUI interface.
So I think we have now an answer to the question :
Non-modal dialogs are possible and easy in Open Office.
Perhaps developpers could integrate something more clean than my dirty workaround to display non-modal dialogs. All the basic mecanic is already present, so this should not be complicated.
Here is the summary of the code necessary to display a non-modal dialog Dialog1 of the library "modaless", provided the Dialog1 has a toggle button which name is CloseButton, to close the dialog.
=========================
Sub dialog_modal()
dim dlg as object
dim n as integer
dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true
do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop
exit sub
That's all guys. Enjoy. _________________ Dysmas |
|
| Back to top |
|
 |
pradhan General User


Joined: 01 Sep 2006 Posts: 48
|
Posted: Sun May 06, 2007 11:56 pm Post subject: |
|
|
I tried this code but i get a runtime error :
| Quote: | Sub dialog_modal()
dim dlg as object
dim n as integer
dlg = loadDialog ("modaless","Dialog1")
dlg.visible = true
do
n = dlg.model.CloseButton.State
if n = 1 then exit do
wait (100)
loop
exit sub |
the errore says "sub or function not defined" in line
| Code: | | dlg = loadDialog ("modaless","Dialog1") |
What am I missing ? |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|