Hi Laszlo, and welcome to the list if you are new here,
the reason why your class breaks sometimes I believe is the following:
when the Login window object is created, the entire application is
probably not completely rendered, so that app's root's bounds are indeed
null.
You might add a listener to your app which would execute as soon as the
root appears, and initialize (i.e. this.__login.init(this);) the object
from within the listener function. For this purpose, the application
root, which is a qx.ui.core.Widget, fires an "appear" event. "resize"
event does also apply, and may sometimes fit better.
Alternatively your Login window might use its "center()" method like so:
this.root.add(this,{left:bounds.width/2, top:bounds.height/2});
this.open();
this.addListenerOnce("appear", function() {
this.center();
}, this);
(not tested in playground, but you should get the idea).
There are probably lots of other ways to handle this stuff.
The reason why the alert() changes the app's behaviour is that it
blocks, and consequently the app is rendered *before* bounds gets its
dimensions.
Qooxdoo's layout manager does its magic asynchronously, which may lead
to such behaviour. You'll soon acquire its advantages and get used to it
;-)!
HTH,
greetings
Stefan
On 27.11.2010 20:50, nagylzs wrote:
>
> Hi,
>
> I'm very beginner so please be patient. I'm trying to write an application
> that opens a modal login window. This is the class for the login window. (It
> is not finished).
>
>
>
> qx.Class.define("phpreport_frontend.Login",
> {
> extend : qx.ui.window.Window,
> members :
> {
> construct : function() {
> this.base(arguments, "Bejelentkezés");
> },
> init : function(app)
> {
> this.app = app;
> this.root = this.app.getRoot();
> var bounds = this.root.getBounds();
>
> var layout = new qx.ui.layout.Grid(10,10);
> var c = this.__container = new qx.ui.container.Composite();
> this.__container.setLayout(layout);
>
> c.add(new qx.ui.basic.Label("User"), {row: 0, column: 0});
> c.add(new qx.ui.basic.Label("Password"), {row: 1, column: 0});
>
> this.eLogin = new qx.ui.form.TextField();
> this.ePwd = new qx.ui.form.PasswordField();
>
> c.add(this.eLogin, {row: 0, column: 1});
> c.add(this.ePwd, {row: 1, column: 0});
>
> this.root.add(this,{left:bounds.width/2, top:bounds.height/2});
> this.open();
> }
> }
> });
>
>
> If I try to create this from my application like:
>
>
> this.__login = new phpreport_frontend.Login("Login form");
> this.__login.init(this);
>
>
> Then I get this error message:
>
> bounds is null
> [Break on this error] this.root.add(this,{left:bounds.width/2,
> top:bounds.height/2});
>
> However, if I try do this:
>
> this.root = this.app.getRoot();
> alert(this.root);
> var bounds = this.root.getBounds();
>
> Then it throws up an alert window with "qx.ui.root.Appliacation[35]" and
> then it works!
>
> Why is that? How does an "alert()" call affect any other part of my code?
>
> (Tested on Firefox 3.6.12)
>
> Thanks
>
> Laszlo
>
------------------------------------------------------------------------------
Increase Visibility of Your 3D Game App & Earn a Chance To Win $500!
Tap into the largest installed PC base & get more eyes on your game by
optimizing for Intel(R) Graphics Technology. Get started today with the
Intel(R) Software Partner Program. Five $500 cash prizes are up for grabs.
http://p.sf.net/sfu/intelisp-dev2dev
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel