On Thursday, April 17, 2014 3:28:07 PM UTC+1, Danielo Rodríguez wrote:
>
> Hello BJ
>
> Thank you very much for the link.
>
>
> I used to see the widgetName=new Widget
>
> I understand that you are extending an existing tiddler, but I don't 
> understand this lines
>
> var DropZoneWidget = 
> require("$:/core/modules/widgets/dropzone.js")["dropzone"];
> var Widget = require("$:/core/modules/widgets/widget.js").widget;
> /*
>
> If the dropzone widget has already required the widget.. Why are you 
> requiring it again?
>
>
>
> *
> overload the base widget class initialise
> */
> DropZoneWidget.prototype.initialise = function(parseTreeNode,options) {
>       Widget.prototype.initialise.call(this,parseTreeNode,options);
>       this.addEventListeners([
>               {type: "tw-dropHandled", handler: "handleDropHandled"}]);
> };
>
> you are right it is easier to do it like this

DropZoneWidget.prototype.initialiseold = DropZoneWidget.prototype.initialise;
DropZoneWidget.prototype.initialise = function (parseTreeNode,options) {
        DropZoneWidget.prototype.initialiseold.call(this,parseTreeNode,options);
        this.addEventListeners([
                {type: "tw-dropHandled", handler: "handleDropHandled"}]);
};

 

> Why do you call the widget initialise? And why do you add the event handlers 
> here? I thought this is normal in the render function. I readed again the 
> dropzone code and It never raises a tw-dropHandled event. Where is that event 
> raised?
>
> there are two flavors of events dom events and widget-tree events, this is 
a widget-tree event and they are attached to nodes in the widget tree, so 
it makes sense to have them created in the constructor. The event is raised 
by the taglist widget, it handles most of the drag and drop (created by a 
dom drop event), but the final clean-up must handled by the drop-zone widget

>
> Thank you very much
>
>
> El jueves, 17 de abril de 2014 13:33:18 UTC+2, BJ escribió:
>>
>> Its only javascript stuff.
>> I adapt a couple of widgets (link, dropzone) in my taglist plugin - its 
>> fairly straight forward:
>> https://github.com/buggyj/TW5-taglist
>> cheers
>>
>> BJ
>>
>> On Thursday, April 17, 2014 1:17:37 AM UTC+1, Danielo Rodríguez wrote:
>>>
>>> Hello everybody. 
>>>
>>> How can I extend the functionality of an existing widget? Something 
>>> similar than Codemirror does. Is there any mechanism or is just a matter of 
>>> use regular javascript? I'll appreciate any help. 
>>>
>>> Thanks in advance. 
>>>
>>>

-- 
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/tiddlywikidev.
For more options, visit https://groups.google.com/d/optout.

Reply via email to