Skip to content
Javier Pedemonte edited this page Aug 19, 2011 · 1 revision

Table of Contents

About this wiki page

NOTE: THIS WIKI PAGE MIGHT CONTAIN OUTDATED TECHNICAL INFORMATION. CONTENT WAS LAST UPDATED 02/2010

This wiki page attempts to provide an inventory of the places in the where (widget) selection change event handlers are registered and recommend how to improve the code in the future.

Current selection change event listeners and publishers

Widget selection changes go through the select() method in Context.js, which then invokes the onSelectionChange() method in Context.js. Code can listen to selection changes by either

  • invoking dojo.connect on the onSelectionChange() method in Context.js, or
  • subscribing to "/bbt/ui/selectionChanged"
However, only some parts of daVinci are invoking dojo.publish("/bbt/ui/selectionChanged", ...). For example, _updateMainToolbar() in Workbench.js subscribes to "/bbt/ui/selectionChanged". If you change selection by clicking on the canvas, _updateMainToolbar() doesn't get called. However, if you change selection by clicking in the Outline palette, then OutlineView.js calls dojo.publish(), so _updateMainToolbar() gets invoked.

using dojo.connect()

  • bbt/htmledit/VisualEditor.js(73): this._handles.push(dojo.connect(this.context, "onSelectionChange",...
  • bbt/htmledit/ObjectView.js(58): this._connect("onSelectionChange","_selectionChanged");
  • bbt/htmledit/VisualEditor.js(73): this._handles.push(dojo.connect(this.context, "onSelectionChange",this, this.onSelectionChange));
  • bbt/htmledit/VisualEditorOutline.js(15): this._connect("onSelectionChange", "onSelectionChange");
  • bbt/htmledit/properties/PropertiesView.js(154): this._connects.push(dojo.connect(this._context, "activate", this, this._selectionChanged));
  • bbt/htmledit/properties/PropertiesView.js(157): this._connects.push(dojo.connect(this._context, "onSelectionChange",this, this._selectionChanged));
  • bbt/htmledit/properties/page/StyleAlpha.js(68): this._connects.push(dojo.connect(this._context, "onSelectionChange",this, this.update));
  • bbt/themeEditor/ThemeEditor.js(472): dojo.connect(this._visualEditor, "onSelectionChange",this, "onSelectionChange");
  • bbt/themeEditor/VisualThemeEditor.js(37): dojo.connect(this.context, "onSelectionChange",this, "onSelectionChange");
  • dojoy/htmledit/Outline.js(55): this.connect(context, "onSelectionChange", "onSelectionChange");

using dojo.publish() and dojo.subscribe

  • bbt/Workbench.js(31): bbt.Runtime.subscribe("/bbt/ui/selectionChanged",bbt.Workbench._updateMainToolBar );
  • bbt/runtime.js(56): this.subscribe("/bbt/ui/selectionChanged",bbt.Runtime._selectionChanged );
  • bbt/ui/Explorer.js(42): function(event){dojo.publish("/bbt/ui/selectionChanged",
  • bbt\ui\OutlineView.js(132): if (this.publishing["/bbt/ui/selectionChanged"])
  • bbt/ui/modelEditor.js(11): this.subscribe("/bbt/ui/selectionChanged", this.selectModel);
  • bbt/htmledit/ObjectView.js(31): dojo.subscribe("/bbt/ui/selectionChanged", dojo.hitch(this, this._selectionChanged));
  • bbt/themeEditor/ThemeEditor.js(471): this._subscriptions.push(dojo.subscribe("/bbt/ui/selectionChanged", dojo.hitch(this, this._outlineSelectionChanged)));
  • dojoy/runtime/States.js(379):dojo.subscribe("/bbt/ui/selectionChanged", function(selection){

Proposed strategy going forward

In Context.js, the onSelectionChange() routine should call dojo.publish("/bbt/ui/selectionChanged",...) or whatever we decide to call the event. That way, logic within the core of daVinci can use dojo.connect() and plugin modules can get notified via pubsub.

Clone this wiki locally