Design-Flaw in navigator?

49 views
Skip to first unread message

Mirko Richter

unread,
Dec 23, 2020, 8:35:25 AM12/23/20
to TiddlyWikiDev

Hi,

i tried to sublass the navigator as described in "WidgetSubclassingMechanism" like so:


(function(){

    /*jslint node: true, browser: true */
    /*global $tw: false */
    "use strict";
    
    exports.baseClass = "navigator";
    
    // Specify a different name to make the subclass available as a new widget instead of overwriting the baseclass:
    exports.name = "limited-stack-navigator";
    
    exports.constructor = function(parseTreeNode,options) {
        this.initialise(parseTreeNode,options);
    };
    
    exports.prototype = {};
    
    exports.prototype.handleNavigateEvent = function(event) {
        /*event = $tw.hooks.invokeHook("th-navigating",event);
        if(event.navigateTo) {
            this.addToStory(event.navigateTo,event.navigateFromTitle);
            if(!event.navigateSuppressNavigation) {
                this.addToHistory(event.navigateTo,event.navigateFromClientRect);
            }
        }*/
        console.log("HANDLE");
        return false;
    };
    
    })();

I get the following error: "this.eventListeners is undefined". It seems that the constructor of widget (the baseclass of navigator) is not called beforehand (which registers this.eventListeners ). So my basic questions here are:
  1. is this a design flaw? (e.g. the registration for the events inside of the navigator-constructor is a bad idea ;) )
  2. is it not intended to subclass navigator from some reason?
  3. am i doing something else (more trivial) wrong in my overwrite-trial above?

Thanks for your help,
Mirko

Jeremy Ruston

unread,
Dec 23, 2020, 8:53:18 AM12/23/20
to tiddly...@googlegroups.com
Thanks Mirko, that does indeed seem to be a bug with the subclassing mechanism. The code fails when the base class is set to any of the widgets that set event handlers in their constructor (eg <$scrollable>), but works for other widgets. I wonder if you’d kindly be able to create a GitHub ticket?

Many thanks,

Jeremy

--
You received this message because you are subscribed to the Google Groups "TiddlyWikiDev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywikide...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/b63933cd-ba27-4de1-9bfa-1d44327bd202n%40googlegroups.com.

Mirko Richter

unread,
Dec 23, 2020, 9:20:22 AM12/23/20
to TiddlyWikiDev

Regards,
Mirko
Reply all
Reply to author
Forward
0 new messages