On Mon, May 10, 2010 at 09:38, msaladin <[email protected]> wrote:

>
> Hi Derell,
>
> thanks a lot for your prompt answer. I tried it by using an own private
> instance variable in the subclass for "__ignoreClick", and it works good
> (source is attached), but this solves the problem by invoking a new one:
> now
> my implementation accesses the private instance variable
> "this.__resizeColumn" from the superclass.
>
> And this instance variable is unfortunately used at several places in the
> superclass, so I would have to reimplement all those methods, too, and
> maybe
> there are yet other private instance variables that are used in those new
> methods... leading to have the source code of many methods redundant?
>

Yeah, that was pretty silly of me. Are you unable to do all of your own
processing without the need for that variable, and then just call the
superclass? Just like I showed for _onClickHeader where it tested using
private variables of the subclass whether there was something special to do,
and if not, just call the superclass, can you do something similar in
_onMouseupHeader? The problem is that you're getting into the internal
workings of the widget that you're really not supposed to mess with yourself
(which is why they're private). I suspect (and hope) that a slight
reorganization of your subclass code would allow you to determine if the
click was pertaining to your own needs, and if not, to simply call the
superclass. That's really the "right" way to do this, if at all possible.

Derrell




> Regards
> Michael
>
>
> qx.Class.define("hello.TgridScroller",
> {
>  extend : qx.ui.table.pane.Scroller,
>
>   construct : function(table) {
>    this.base(arguments, table);
>  },
>
>  members: {
>    __tgridIgnoreClick : false,
>
>
>    /**
>    * Overwrites the onMouseup
>    *
>    * because the private variable "__tgridIgnoreClick" cannot be used in
> the
>    * subclass.
>    */
>     _onMouseupHeader : function(e) {
>      var table = this.getTable();
>
>      if (! table.getEnabled()) {
>        return;
>      }
>
>      if (this.__resizeColumn != null) {
>         this.__tgridIgnoreClick = true;
>        // Let the superclass do the logic from here on, we have set our
> variable:
>        this.base(arguments, e);
>       } else if (this.__moveColumn != null) {
>         // Let the superclass do the logic from here on, we have set our
> variable:
>        this.base(arguments, e);
>      }
>    },
>
>    /**
>     * Overwrites the onClick
>     *
>     * because T-GRID allows filters (textfields, dropdowns etc...) in the
> header of
>     * a table, therefore, the onClick event must be able to determine
> whether the
>     * user clicked inside the background of the header (to sort it or to
> move the
>     * column) or inside one of the filter widgets.
>     *
>     * @param e {Map} the event.
>     * @return {void}
>     */
>    _onClickHeader : function(e) {
>      if (this.__tgridIgnoreClick) {
>        this.__tgridIgnoreClick = false;
>        return;
>       }
>
>      var table = this.getTable();
>      if (!table.getEnabled()) {
>        return;
>      }
>
>       var tableModel = table.getTableModel();
>      var doSort = false;
>      var pageX = e.getDocumentLeft();
>      var resizeCol = this._getResizeColumnForPageX(pageX);
>      if (resizeCol == -1) {
>        // mouse is not in a resize region
>        var col = this._getColumnForPageX(pageX);
>        if (col != null && tableModel.isColumnSortable(col)) {
>          // Normally the column should be sorted now, but we should check
> whether the
>          // header widget is one of our own. If yes, it could be that the
> user clicked
>          // on a widget or our filter. In this case, we should not sort it,
> but pass
>          // the event on.
>          doSort = true;
>
>          var headerWidget = this.getHeader().getHeaderWidgetAtColumn(col);
>          if (headerWidget) {
>            // Is it one of my own header widgets? I know that I defined a
> member method
>            // called "isInFilterArea", if this one is defined I can
> actually invoke it.
>            if (headerWidget.isInFilterArea) {
>              var pageY = e.getDocumentTop();
>              if (headerWidget.isInFilterArea(pageX, pageY)) {
>                doSort = false;
>              }
>            }
>          }
>        }
>      }
>
>      if (doSort) {
>        // Let the superclass do the sorting:
>        this.base(arguments, e);
>      }
>
>      e.stop();
>    }
>
>  }
> });
>
>
>
> --
> View this message in context:
> http://qooxdoo.678.n2.nabble.com/Subclassing-Scroller-js-tp5030157p5030609.html
> Sent from the qooxdoo mailing list archive at Nabble.com.
>
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> qooxdoo-devel mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel
>



-- 
"There are two ways of constructing a software design.
One way is to make it so simple that there are obviously no deficiencies.
And the other way is to make it so complicated that there are no obvious
deficiencies."

                                               C.A.R Hoare
------------------------------------------------------------------------------

_______________________________________________
qooxdoo-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/qooxdoo-devel

Reply via email to