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 > On 23 Dec 2020, at 13:35, Mirko Richter <compago...@gmail.com> wrote: > > > 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: > is this a design flaw? (e.g. the registration for the events inside of the > navigator-constructor is a bad idea ;) ) > is it not intended to subclass navigator from some reason? > am i doing something else (more trivial) wrong in my overwrite-trial above? > > Thanks for your help, > Mirko > > -- > 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 tiddlywikidev+unsubscr...@googlegroups.com > <mailto:tiddlywikidev+unsubscr...@googlegroups.com>. > To view this discussion on the web visit > https://groups.google.com/d/msgid/tiddlywikidev/b63933cd-ba27-4de1-9bfa-1d44327bd202n%40googlegroups.com > > <https://groups.google.com/d/msgid/tiddlywikidev/b63933cd-ba27-4de1-9bfa-1d44327bd202n%40googlegroups.com?utm_medium=email&utm_source=footer>. -- 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 tiddlywikidev+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywikidev/F1D29026-3B57-450A-97A6-89E956BD7342%40gmail.com.