This repository has been archived by the owner on Jun 2, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 19
WorkingWithSelection
StarUML edited this page Jan 18, 2015
·
6 revisions
In this chapter, we're going to learn how to get selected elements, enforce to select elements, and do something by listening selection changed events.
Users can select elements in a diagram or in Explorer. Sometimes we may need to access only the selected elements. To get selected elements we need SelectionManager module.
var SelectionManager = app.getModule('engine/SelectionManager');
Before to get detail, we need to distinguish between selected views and selected models. If you select the Book class in a diagram, then there are a selected view (UMLClassView
) and a selected model (UMLClass
). If you select the Author class in Explorer, then there is a selected model (UMLClass
) and no selected views.
We can access to selected elements using SelectionManager as following:
var selectedViews = SelectionManager.getSelectedViews();
var selectedModels = SelectionManager.getSelectedModels();
var selected = SelectionManager.getSelected(); // === selectedModels[0]
TODO...
TODO...