Hi,
the problem is that in your example the scope from your listener
function is wrong, when the function is called. The 'this' doesn't point
to the LoginWindow to set the right scope use that instead:
this.__widgets["okbutton"].addListener( "click", function(e)
{
alert(this.__widgets["namefield"].getValue());
}, this); //<-- set the right scope for the 'this'
Cheers,
Chris
sNIk schrieb:
> hello there. i have the following class for login. (simplified)
>
>
> ------------------------------------------------------------------------------------------------------
>
> qx.Class.define("qxgui.layout.LoginWindow",
> {
> extend: qx.core.Object,
> type: "singleton",
>
> construct : function()
> {
> this.__widgets = {};
>
> // labels
> ...
>
> // input-felder
> ...
>
> // button
> ...
>
> this.__widgets["okbutton"].addListener( "click", function(e)
> {
> alert(this.__widgets["namefield"].getValue());
> });
>
> this.__createWindow();
> },
>
> members:
> {
> // eigenschaften
>
> ////////////////////////////////////////////////////////////////////////
>
> __window: null,
> __widgets: null,
>
>
> // methoden
>
> ////////////////////////////////////////////////////////////////////////
>
> /* login-fenster öffnen */
> openLoginWindow: function()
> {
> this.__window.add( this.__createForm() );
> this.__window.open();
> this.__window.center();
>
> var app = qx.core.Init.getApplication().getRoot();
> app.add( this.__window );
>
> /* automitisches zentrieren des fensters */
> app.addListener("resize", function(e)
> {
> this.center();
> },
> this.__window);
> },
>
> /* login-fenster erstellen */
> __createWindow: function( form )
> {
> this.__window = new qx.ui.window.Window("Login");
> this.__window.setLayout( new qx.ui.layout.Grow() );
>
> this.__window.setShowMaximize( false );
> this.__window.setShowMinimize( false );
> this.__window.setAllowMaximize(false);
> this.__window.setAllowMinimize(false);
>
> this.__window.setWidth(250);
> this.__window.setHeight(198);
>
> this.__window.setShowStatusbar(true);
> this.__window.setStatus("Status");
> },
>
> /* login-form erstelen */
> __createForm: function()
> {
> ...
>
> form.add( this.__widgets["namefield"], {row: 0, column : 1});
> form.add( this.__widgets["pwfield"], {row: 1, column : 1});
> form.add( this.__widgets["okbutton"], {row : 3, column : 1} );
>
> return form;
> }
> }
> });
>
> ------------------------------------------------------------------------------------------------------
>
> i get this error on "click":
>
> this.__widgets is undefined
> [Break on this error] alert(this.__widgets["namefield"].getValue());
>
> the window shows up correctly, just the properties are not accessible for
> some reason. maybe im just too tired today. ;) but i must admin that im not
> an js-expert. coding for few days now.
>
> thank you in advance! going to bed now ...
>
>
------------------------------------------------------------------------------
Stay on top of everything new and different, both inside and
around Java (TM) technology - register by April 22, and save
$200 on the JavaOne (SM) conference, June 2-5, 2009, San Francisco.
300 plus technical and hands-on sessions. Register today.
Use priority code J9JMT32. http://p.sf.net/sfu/p
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel