| | 786 | |
|---|
| | 787 | MochiKit.Signal |
|---|
| | 788 | =============== |
|---|
| | 789 | |
|---|
| | 790 | * Crown jewels of MochiKit 1.3 |
|---|
| | 791 | * Sorry it took so long |
|---|
| | 792 | * Events in browsers totally suck |
|---|
| | 793 | |
|---|
| | 794 | |
|---|
| | 795 | What sucks about browser events? |
|---|
| | 796 | ================================ |
|---|
| | 797 | |
|---|
| | 798 | * IE is totally different |
|---|
| | 799 | * IE's garbage "collector" |
|---|
| | 800 | * Safari needs help |
|---|
| | 801 | * They all disagree on pixel positions |
|---|
| | 802 | * Damn near impossible to get key events to work properly cross-platform |
|---|
| | 803 | |
|---|
| | 804 | |
|---|
| | 805 | connect and DOM |
|---|
| | 806 | =============== |
|---|
| | 807 | |
|---|
| | 808 | This works everywhere:: |
|---|
| | 809 | |
|---|
| | 810 | function myClick(e) { |
|---|
| | 811 | var mouse = e.mouse(); |
|---|
| | 812 | log("page coordinates: " + mouse.page); |
|---|
| | 813 | log("client coordinates: " + mouse.client); |
|---|
| | 814 | } |
|---|
| | 815 | connect("element_id", "onclick", myClick); |
|---|
| | 816 | |
|---|
| | 817 | |
|---|
| | 818 | Not Really The Event Object |
|---|
| | 819 | =========================== |
|---|
| | 820 | |
|---|
| | 821 | * MochiKit.Signal gives you a consistent event object, NOT the browser's. |
|---|
| | 822 | * e.type() is the event type (doesn't include the "on" prefix) |
|---|
| | 823 | * e.target() is the event target |
|---|
| | 824 | * e.mouse() has consistent client and page coordinates |
|---|
| | 825 | * e.key() has consistent keyboard state |
|---|
| | 826 | * ... and consistent key codes and key names!!@#! |
|---|
| | 827 | * e.stop() does both W3C stopPropagation and preventDefault for convenience |
|---|
| | 828 | |
|---|
| | 829 | |
|---|
| | 830 | Not Just For Browser Events |
|---|
| | 831 | =========================== |
|---|
| | 832 | |
|---|
| | 833 | * Can register your own signals for your own objects |
|---|
| | 834 | * Arbitrary event broadcasting |
|---|
| | 835 | * This feature is not currently used internally or in any examples, |
|---|
| | 836 | though it is documented and tested |
|---|
| | 837 | |
|---|
| | 838 | |
|---|
| | 839 | MochiKit on the Web |
|---|
| | 840 | =================== |
|---|
| | 841 | |
|---|
| | 842 | Home page: |
|---|
| | 843 | http://mochikit.com/ |
|---|
| | 844 | |
|---|
| | 845 | Bug tracker/Wiki: |
|---|
| | 846 | http://trac.mochikit.com/ |
|---|
| | 847 | |
|---|
| | 848 | Subversion repository: |
|---|
| | 849 | http://svn.mochikit.com/ |
|---|
| | 850 | |
|---|
| | 851 | |
|---|
| | 852 | MochiKit Support |
|---|
| | 853 | ================ |
|---|
| | 854 | |
|---|
| | 855 | - Check the documentation |
|---|
| | 856 | - Ask on the mailing list |
|---|
| | 857 | - Check the wiki/bug tracker |
|---|
| | 858 | - #mochikit on irc.freenode.net |
|---|