1

Can you know which tab is currently opened in the blockly toolbox? If so, can anyone show me an example or code snippet?

Timo Herngreen
  • 112
  • 1
  • 9

2 Answers2

1

The toolbox contains a Closure UI Tree.

To get the name of the most recent tab while accessing a minimum set of private members:

var tree = workspace.getToolbox().tree_;  
var selectedItem = tree.getSelectedItem();
if (selectedItem) {
  var itemText = selectedItem.getText();
} else {
  console.log('no item selected');
}
fennel
  • 371
  • 2
  • 11
0

I found the answer by doing trial and error things!

[workspace here].toolbox_.lastCategory_.html_.privateDoNotAccessOrElseSafeHtmlWrappedValue_

stores a string whith the most recent selected tab, and

workspace.toolbox_.lastCategory_.selected_

gives a boolean which lets you know if the last selected tab is currently selected.

Timo Herngreen
  • 112
  • 1
  • 9