Hi François,

var someObject = {}
function func(obj, str){
     alert(obj.abc);
     alert(obj.def);
     alert(str);
}

connect(someObject, 'pouf', myObject.func);
signal(someObject, 'pouf', {abc:'yes', def:'no'}, 'last');

Notice that the extra parameters passed in signal() are passed onto  
the function. The e.event() method is only available on the single  
parameter passed when a native browser event is executed. I think  
this is the source of your misunderstanding.

As for a good example of custom events, I haven't had the time to  
cook one up. Does anyone have a good example?

On 3-May-06, at 11:04 AM, François wrote:

>
> Beau Hartshorne wrote:
>
>> If this doesn't clear things up, please post some code with your
>> actual/expected results to the list.
>
>
> Thanks for the quick answer.  Some code to clear things up for me:
>
> BEGIN CODE
> ++++++++++++++++++++++++++++
>
> var ident1, ident2, ident3, ident4;
>
> var myObject = {};
>
> myObject.func = function(e){
>
>
>       alert(e.event().abc); // Want to get to the object passed as the
> argument with //signal()
>
>
> }
>
> var pack = {};
>
> pack.aler = function(e){
>
>               signal('someEnclosingDiv','pouf', {abc:'yes', def:'no'});
>
> };
>
> function setup(){
>
>         ident1 = connect("discon", "onclick", discon);
>         ident2 = connect("alink", "onclick", pack, 'aler');
>         englob = connect("someEnclosingDiv", 'pouf', myObject.func);
> }
>
> ident3 = connect(window, "onload", setup);
>
> function discon (){
>
> disconnect(ident1);
> disconnect(ident2);
> disconnect(ident3);
> ident4 = connect("con", "onclick", con);
>
> }
>
> function con (){
>
>         ident1 = connect("discon", "onclick", discon);
>         ident2 = connect("alink", "onclick", pack, 'aler');
>       disconnect(ident4);
>
> }
>
> ++++++++++++++++++++++++++++
> END CODE
>
> This bit of code basically sets three links to use the connection,
> disconnect all signals, and a third one to reconnect them.
>
> I do get the alert "no" from the argument passed with signal(), but I
> was just wondering, in my first post, if this was the proper way to  
> get
> to it from within the slot.  Is there any other way to retrieve the
> argument when using, as I did here, a custom event?
>
>
>
> Can I bother you with this other question?  Please ignore it if it's
> too general.
>
> What I want to accomplish here is a 'chain' of events that will
> trigger, at the upper level of my DOM tree (someEnclosingDiv), a
> specific reaction, related to a specific event lower down the tree (a
> link in this case, enclosed in the former).
>
> What is the proper or more common structure to accomplish this?
> Basically, I want the upper level div to react, say, to a 'close'
> signal from a button, or to some other event from another button, and
> keep all the "parts" involved as loosely coupled as possible.
>
> I've searched for patterns, or some indication, but found nothing
> satisfying.  I haven't programmed much with QT, so lack the experience
> in GUI programming that would be handy in this situation.
>
> Thanks,
>
> F.
>
>
> >


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"MochiKit" group.
To post to this group, send email to mochikit@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/mochikit
-~----------~----~----~----~------~----~------~--~---

Reply via email to