[Laszlo-user] datacombobox suggestion for enhancement

William Krick wkrick at eio-online.com
Tue Apr 11 09:40:54 EDT 2006


We've made a change to basedatacombobox.lzx so that _cblist is destroyed
every time the popup list is closed.  This is necessary to keep our app's
memory usage down.  If we don't do this, as more and more datacomboboxes are
opened, the memory size climbs to the point that our app becomes unusably
slow.

We find this technique useful but it's not always desirable so it would nice
if it was a non-default option that could be turned off and on as necessary.
I'm not sure what to call the option or how to implement it.

The change to destroy _cblist is just two lines at the end of the "setOpen"
method...


<!--- Sets the open/close state of the popup list.
      @param Boolean open: true to open the list, else false to close.
      -->
<method name="setOpen" args="open" ><![CDATA[
    if (!this._initcomplete) {
        this.isopen = open;
        return;
    }
    if (open) { // open combox
        if (this.isopen) return; // tends to get called more than once

        LzModeManager.makeModal( this );

        this._setupcblist();

        this._cblist.bringToFront();
        this._cblist.setVisible(true);

        LzFocus.setFocus( this._cblist, false );

        this.isopen = true;
        if (this['onisopen']) this.onisopen.sendEvent(true);
    } else { // close combox
        if (!this.isopen) return;
        LzModeManager.release( this );
        if (!this['isopen']) return;
        this._cblist.setVisible(false);
        this.isopen = false;
        if (this['onisopen']) this.onisopen.sendEvent(false);
        if ( LzFocus.getFocus() == this._cblist ) {
            if ( this.focusable ) {
                LzFocus.setFocus( this, false );
            }
        }

        // destroy the list when it closes to reduce memory usage
        this._cblist.destroy();
        this._cblist = null;
    }
    ]]>
</method>





More information about the Laszlo-user mailing list