Question

I am currently trying to mimic the enyo.Popup behavior. I looked at the source at github but having a hard time to understand it.

Especially that is the code I have trouble with:

handlers: {
    //...
    onRequestShow: "requestShow",
    onRequestHide: "requestHide"
},

//* @public
events: {
    //* Fires after the popup is shown.
    onShow: "",
    //* Fires after the popup is hidden.
    onHide: ""
},

And some where else in the code, there are calls to this.show().

Firstly, I did not found a declaration for this.show(). Secondly, though I assume that it must be inside this.show() and this.hide() respectively, where are the onShow and onHide events called?

And lastly, I defined a kind of myself, containing also the above code. But despite the show() and hide() methods are working, my own requestShow() and requestHide() methods were not called.

What am I missing?

Was it helpful?

Solution

Firstly, show is a function declared on enyo.Control: http://enyojs.com/api/#enyo.Control::show

onShow and onHide are events that can be subscribed to by the popup's owner (hence, their declaration in the events block). They are called in the showingChanged function. The method for calling events is do{EventNameWithoutOn}. In this case: doShow.

Check this documentation on events: https://github.com/enyojs/enyo/wiki/Event-Handling
(Or, you could buy my nice Enyo book! http://roysutton.com/2013/01/31/print-book-now-available/ )

The handlers block is a way for a control to subscribe to messages it (or its children) generate. Having said that, I don't see any place in the code that generates onRequestHide events.

I hope that helps!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top