On 07/05/2011 03:13 PM, Simone Pandolfo wrote:
> Hi Daniel,
>
> Thank you, your suggestion is very interesting.
> About the reuse of objects, there is a way for reset to default all the
> widget? i see in the api viewer different reset function, there is one
> for revert to the init status the widget?
>
> In another project i'm creating a parser that create objects from a
> list, and put the unused object in another array, if i want to reuse
> these objects, some time i see the old properties.
> Regards
>   Sp

Interesting question. Unfortunately, there's no reliable way to reset a 
qx object to its initial state. You could use 
qx.util.PropertyUtil.getProperties to iterate over all the widget's 
properties and reset them, but there are other ways aside from 
properties that widgets can use to store their state, such as private 
members. Also, there are the appearance states ("focused", "hovered", 
etc.) that you'd probably have to remove manually. It would likely be 
necessary to extend each widget you wish to reuse and add a custom reset 
method.

In the end, it's a trade-off: For a large application with complex 
controls, it may well be worth the effort. For a smaller application, 
it's probably enough to reuse widgets that don't have many dynamic 
properties.


Regards,
Daniel

>
> Il giorno mar, 05/07/2011 alle 14.31 +0200, Daniel Wagner ha scritto:
>> Hi Simone,
>>
>> your code fails because when you destroy the Window, it destroys its
>> children, including the ColorSelector. Then on the second button press,
>> you're trying to add the disposed selector to the new Window which
>> causes the exception. So a quick fix would be to move the ColorSelector
>> instantiation into the "execute" listener callback function.
>>
>> However, that would still create a new Window every time the button is
>> clicked, which is not what you want (and would be a bad idea since
>> creating objects is expensive). Instead, you could implement the
>> Singleton pattern. Your button listener would just look like this:
>>
>>         button1.addListener("execute", function(e) {
>>           this._getWindow().open();
>>         }, this);
>>
>> While _getWindow would be a new method that makes sure only one instance
>> is created:
>>
>>       _getWindow : function()
>>       {
>>         if (!this.__window) {
>>           var selector = new qx.ui.control.ColorSelector();
>>           var window = this.__window = new qx.ui.window.Window();
>>           window.setModal(true);
>>           window.setLayout(new qx.ui.layout.Basic() );
>>           window.add(selector);
>>         }
>>         return this.__window;
>>       }
>>
>>
>> Regards,
>> Daniel
>>
>> On 07/05/2011 01:44 PM, Simone Pandolfo wrote:
>>> Hi all,
>>>
>>> i'm trying to have one signle istance of an object, i write a short
>>> example:
>>> http://tinyurl.com/67fx8hs
>>>
>>> inside a button listener i create an window object and add to it a
>>> listener "beforeClose" to destroy it, but at the next "execute" of the
>>> button the window don't be create again and throw an error.
>>>
>>> Uncaught TypeError: Cannot read property '__fn' of null
>>>
>>> I need this because i want hide all the other window, and after show
>>> again, but if i don't destroy the object i see the window twice, the old
>>> istance and the new one.
>>>
>>> what i wrong?
>>>
>>> Best Regards
>>>    Sp
>>>
>>
>> ------------------------------------------------------------------------------
>> All of the data generated in your IT infrastructure is seriously valuable.
>> Why? It contains a definitive record of application performance, security
>> threats, fraudulent activity, and more. Splunk takes this data and makes
>> sense of it. IT sense. And common sense.
>> http://p.sf.net/sfu/splunk-d2d-c2
>> _______________________________________________
>> qooxdoo-devel mailing list
>> [email protected]
>> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>>
>

------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security 
threats, fraudulent activity, and more. Splunk takes this data and makes 
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to