For an example, I would like to show multiple windows, so I try to use the mode WindowMode.modeless but I have an exception raised (true for any value of the enum)...
This example:
using fwt
using gfx
class Windows
{
static Void main()
{
Window
{
size = Size(200, 200)
title = "WindowMode.modeless Test"
mode = WindowMode.modeless
}.open
}
}
If I comment out the line mode = WindowMode.modeless the window is displayed correclty...
I must be missing something very obvious but as my background is really far from desktop development (a long time I haven't done Swing code), I have no clue... It must be possible to display multiple windows on the screen.
brianMon 1 Mar 2010
The problem is actually very tricky. The constructor for Window is:
new make(Window? parent := null, |This|? f := null)
So that code is essentially calling:
Window(null, null).with { .... }
Which explains why you get the ConstErr. If you change it to the following then it will work:
Window(null)
{
size = Size(200, 200)
Not sure how to easily fix that gotcha.
lbertrandMon 1 Mar 2010
Many thanks...All is working - missed the constructor taking a first parameter of the parent window...
Next question is how do I display more than 1 window on the desktop? As soon as open is called it shows the window but do not return the hand to the script so will not show the next window...
Script:
using fwt
using gfx
class Windows
{
static Void main()
{
Window(null)
{
size = Size(200, 200)
title = "Window 1"
mode = WindowMode.modeless
}.open
Window(null)
{
size = Size(200, 200)
title = "Window 2"
mode = WindowMode.modeless
}.open
}
}
I am sure I have been able to see some application being able to display multiple windows on the desktop without them having to be inside a window container... Is there a way to do it...
brianMon 1 Mar 2010
Once you open the first window, the thread will block in the SWT event loop.
So additional windows will have to be launched on the event loop. Maybe use Desktop.callAsync
lbertrandMon 1 Mar 2010
I tried but failed...
If I open all the windows using the Desktop.callAsync, it fails as the Main UI thread is not running...
So I need at least to open the 1st window in the script but then cannot call the Desktop.callAsync as the main thread is blocked in the SWT event loop...
I really don't see how to do this! Is there a way to initialize the Main UI loop without blocking the main thread, like a FWT object that do not display anything, so I can then use the Desktop.callAsync to open all my windows
andyMon 1 Mar 2010
You would normally do that from the Window.onOpened callback from the primary window - but doesn't appear we expose that method (assuming SWT supports that concept).
brianMon 1 Mar 2010
If you an actor in your application, then I'd have to your actor use callAsync.
Otherwise if you don't have any UI element which kick this off, you can do off one of the other window state change callbacks using a once method so it is just done at initialization time.
qualidafialThu 4 Mar 2010
How about offering a field blockOnOpen (it could default to true), and exposing the event loop through the fwt::Desktop class?
I think SWT had the right idea when they exposed the event loop as a low-level API. It can be completely optional, but if necessary it's very helpful to be able to plug into it.
lbertrand Mon 1 Mar 2010
For an example, I would like to show multiple windows, so I try to use the mode
WindowMode.modeless
but I have an exception raised (true for any value of the enum)...This example:
throws the following exception:
If I comment out the line
mode = WindowMode.modeless
the window is displayed correclty...I must be missing something very obvious but as my background is really far from desktop development (a long time I haven't done Swing code), I have no clue... It must be possible to display multiple windows on the screen.
brian Mon 1 Mar 2010
The problem is actually very tricky. The constructor for Window is:
So that code is essentially calling:
Which explains why you get the ConstErr. If you change it to the following then it will work:
Not sure how to easily fix that gotcha.
lbertrand Mon 1 Mar 2010
Many thanks...All is working - missed the constructor taking a first parameter of the parent window...
Next question is how do I display more than 1 window on the desktop? As soon as open is called it shows the window but do not return the hand to the script so will not show the next window...
Script:
I am sure I have been able to see some application being able to display multiple windows on the desktop without them having to be inside a window container... Is there a way to do it...
brian Mon 1 Mar 2010
Once you open the first window, the thread will block in the SWT event loop.
So additional windows will have to be launched on the event loop. Maybe use Desktop.callAsync
lbertrand Mon 1 Mar 2010
I tried but failed...
If I open all the windows using the Desktop.callAsync, it fails as the Main UI thread is not running...
So I need at least to open the 1st window in the script but then cannot call the Desktop.callAsync as the main thread is blocked in the SWT event loop...
I really don't see how to do this! Is there a way to initialize the Main UI loop without blocking the main thread, like a FWT object that do not display anything, so I can then use the Desktop.callAsync to open all my windows
andy Mon 1 Mar 2010
You would normally do that from the Window.onOpened callback from the primary window - but doesn't appear we expose that method (assuming SWT supports that concept).
brian Mon 1 Mar 2010
If you an actor in your application, then I'd have to your actor use callAsync.
Otherwise if you don't have any UI element which kick this off, you can do off one of the other window state change callbacks using a once method so it is just done at initialization time.
qualidafial Thu 4 Mar 2010
How about offering a field
blockOnOpen
(it could default totrue
), and exposing the event loop through the fwt::Desktop class?I think SWT had the right idea when they exposed the event loop as a low-level API. It can be completely optional, but if necessary it's very helpful to be able to plug into it.