OpenLayers OpenLayers

Ticket #1346 (closed feature: fixed)

Opened 10 months ago

Last modified 10 months ago

give controls an events instance

Reported by: tschaub Assigned to: tschaub
Priority: minor Milestone: 2.6 Release
Component: Control Version: 2.5
Keywords: Cc:
State: Complete

Description

With this, others can listen for "activate" and "deactivate" events (and more).

Attachments

control_events.patch (9.4 kB) - added by tschaub on 02/09/08 00:03:30.
give controls an events instance
destroy_once.patch (0.6 kB) - added by crschmidt on 02/11/08 09:24:33.
events_check.patch (0.5 kB) - added by tschaub on 02/12/08 11:22:15.
only destroy events if it exists

Change History

02/08/08 23:59:16 changed by tschaub

  • owner set to tschaub.
  • status changed from new to assigned.
  • state set to Review.

With this patch, all controls get an events instance. Controls trigger "activate" and "deactivate" events. The control panel now takes advantage of these events, redrawing itself when appropriate. The navigation history control is now quite a bit simpler as this removes the need for onActivate and onDeactivate stuff.

Tests pass in FF/Safari.

02/09/08 00:03:30 changed by tschaub

  • attachment control_events.patch added.

give controls an events instance

02/09/08 00:46:21 changed by ahocevar

Patch looks good to me. Makes things simpler (as can be seen in the example).

(follow-up: ↓ 4 ) 02/09/08 10:10:36 changed by elemoine

Why does the navigation history control have its own events property? And why that control uses this.map.events instead of this.events for registering event types?

(in reply to: ↑ 3 ; follow-up: ↓ 5 ) 02/09/08 10:22:33 changed by elemoine

Replying to elemoine:

Why does the navigation history control have its own events property? And why that control uses this.map.events instead of this.events for registering event types?

I misread your patch and thought you were adding the events property to the navigation history control. Thanks Chris for making me realize that.

(in reply to: ↑ 4 ) 02/09/08 10:27:02 changed by elemoine

  • state changed from Review to Commit.

Replying to elemoine:

Replying to elemoine:

Why does the navigation history control have its own events property? And why that control uses this.map.events instead of this.events for registering event types?

I misread your patch and thought you were adding the events property to the navigation history control. Thanks Chris for making me realize that.

So the patch looks good to me! Please commit.

02/09/08 11:46:02 changed by tschaub

  • status changed from assigned to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6167]) Giving all controls an events instance. You can now listen for activate and deactivate on any control. Panel controls do this to know when they should redraw. Navigation history control demonstrates the effect of this change. r=elemoine (closes #1346)

02/11/08 08:42:50 changed by bartvde

  • status changed from closed to reopened.
  • resolution deleted.

I am reopening this ticket since I have IE6 crashing on this change when closing the page. Specifically the this.events.destroy() line where it complains this.events is null.

02/11/08 09:06:42 changed by crschmidt

  • state changed from Complete to Needs More Work.

On which line? Which control? The tests don't bring this up anymore, so it's something that isn't tested: can you tell which?

02/11/08 09:17:46 changed by bartvde

Line 168 in http://trac.openlayers.org/browser/trunk/openlayers/lib/OpenLayers/Control.js

If I alert the CLASS_NAME, then the one before the crash is OpenLayers.Control.Button.

I get:

Button
Button
NavigationHistory
Button again

02/11/08 09:19:04 changed by crschmidt

Thanks; this is helpful.

02/11/08 09:24:18 changed by bartvde

I think I might know what's happening, the Map object tries to destroy the controls, but NavigationHistory also destroy next and prev .....

02/11/08 09:24:33 changed by crschmidt

  • attachment destroy_once.patch added.

02/12/08 11:12:59 changed by crschmidt

  • state changed from Needs More Work to Review.

02/12/08 11:22:15 changed by tschaub

  • attachment events_check.patch added.

only destroy events if it exists

02/12/08 11:23:28 changed by tschaub

I'd rather the second.

02/12/08 11:24:35 changed by crschmidt

  • state changed from Review to Commit.

Okay. I'm happy either way: I can't see any way in which it will change things :) Please commit

02/12/08 11:40:30 changed by tschaub

Who knows, someone might extend a control and nullify events themselves. The point is, with these ugly "sanity checks" we should limit how much we assume.

02/12/08 11:43:47 changed by tschaub

  • status changed from reopened to closed.
  • state changed from Commit to Complete.
  • resolution set to fixed.

(In [6230]) Only destroy events if they are not already destroyed. This is relevant for controls with obligate controls. Since the map thinks it is in charge of destroying controls, and parent controls also destroy obligate controls, control.destroy ends up getting called twice. If someone wants to change the way this is handled, we should have a standard property that lets the map know that control.destroy is the responsibility of someone else. r=crschmidt (closes #1346)