Set multiple "measure"'s instances

developer-tools
learning
participation

(Alex Alonso) #1

I’m wondering if there is a way to setup multiple instances of measure
Maybe is not possible thorugh the UI itself, but I’m sure the developers can point me in the right direction on how to do this.


(Patrick Brosset) #2

This is unfortunately not possible through the UI of DevTools.

I’m curious though. Why do you want that to be possible? Interested in understanding if this would be useful to others.

Even by running code, that wouldn’t work I think. You could request several instances of the tool by running code from Scratchpad for example. But everytime you click on the page, all of them will reset their current selection. So you wouldn’t be able to draw several selections at once.

Anyway, in scratchpad (Shift+F4) you can do this:

/* -sp-context:browser */

var { devtools } = Cu.import("resource://devtools/shared/Loader.jsm", {});
var { require } = devtools;
var { gDevTools } = require("devtools/client/framework/devtools");
var t = [...gDevTools._toolboxes][0][1];
var w = t.walker;

async function addMeasuringTool() {
  const h = await t.highlighterUtils.getHighlighterByType("MeasuringToolHighlighter");
  await h.show(w.rootNode);
}

// Add one instance
addMeasuringTool();
// Add another ...