| | 87 | * Property: registeredMethods |
|---|
| | 88 | * {Object} Hash of registered events. Keyed by the name of the event, the |
|---|
| | 89 | * value is an Array of Objects. Each object has two functions: |
|---|
| | 90 | * 'method', the function which the user wishes to register, and |
|---|
| | 91 | * 'registeredFunc', which is a specially created wrapper function |
|---|
| | 92 | * which first sets the 'evt' property on the Handler, and then calls |
|---|
| | 93 | * the previously mentioned 'method'. |
|---|
| | 94 | */ |
|---|
| | 95 | registeredMethods: null, |
|---|
| | 96 | |
|---|
| | 97 | /** |
|---|
| 211 | | this.map.events.registerPriority(name, this, method); |
|---|
| 212 | | this.map.events.registerPriority(name, this, this.setEvent); |
|---|
| | 224 | |
|---|
| | 225 | var wrapperFunction = function(evt) { |
|---|
| | 226 | this.evt = evt; |
|---|
| | 227 | return method.apply(this, [evt]); |
|---|
| | 228 | }; |
|---|
| | 229 | |
|---|
| | 230 | var eventArray = this.registeredMethods.name; |
|---|
| | 231 | if (!eventArray) { |
|---|
| | 232 | this.registeredMethods.name = []; |
|---|
| | 233 | eventArray = this.registeredMethods.name; |
|---|
| | 234 | } |
|---|
| | 235 | var registryEntry = { |
|---|
| | 236 | 'method': method, |
|---|
| | 237 | 'registeredFunction': wrapperFunction |
|---|
| | 238 | }; |
|---|
| | 239 | eventArray.push(registryEntry); |
|---|
| | 240 | |
|---|
| | 241 | this.map.events.registerPriority(name, this, wrapperFunction); |
|---|
| 220 | | this.map.events.unregister(name, this, method); |
|---|
| 221 | | this.map.events.unregister(name, this, this.setEvent); |
|---|
| | 249 | var eventArray = this.registeredMethods.name; |
|---|
| | 250 | if (eventArray) { |
|---|
| | 251 | for(var i=0; i < eventArray.length; i++) { |
|---|
| | 252 | var registryEntry = eventArray[i]; |
|---|
| | 253 | if (registryEntry.method == method) { |
|---|
| | 254 | var registeredFunction = registryEntry.registeredFunction; |
|---|
| | 255 | this.map.events.unregister(name, this, registeredFunction); |
|---|
| | 256 | } |
|---|
| | 257 | } |
|---|
| | 258 | } |
|---|
| 223 | | |
|---|
| 224 | | /** |
|---|
| 225 | | * Method: setEvent |
|---|
| 226 | | * With each registered browser event, the handler sets its own evt |
|---|
| 227 | | * property. This property can be accessed by controls if needed |
|---|
| 228 | | * to get more information about the event that the handler is |
|---|
| 229 | | * processing. |
|---|
| 230 | | * |
|---|
| 231 | | * This allows modifier keys on the event to be checked (alt, shift, |
|---|
| 232 | | * and ctrl cannot be checked with the keyboard handler). For a |
|---|
| 233 | | * control to determine which modifier keys are associated with the |
|---|
| 234 | | * event that a handler is currently processing, it should access |
|---|
| 235 | | * (code)handler.evt.altKey || handler.evt.shiftKey || |
|---|
| 236 | | * handler.evt.ctrlKey(end). |
|---|
| 237 | | * |
|---|
| 238 | | * Parameters: |
|---|
| 239 | | * evt - {Event} The browser event. |
|---|
| 240 | | */ |
|---|
| 241 | | setEvent: function(evt) { |
|---|
| 242 | | this.evt = evt; |
|---|
| 243 | | return true; |
|---|
| 244 | | }, |
|---|