Focus Policy

From IT SPb Academy

Jump to: navigation, search

When you perform some navigation actions, i.e. going to nodes by Ctrl-B, or from tools like find usages or hierarchy view etc., the target node of navigation action performed becomes selected. By default, the cell to select is the first error cell, if such exists, of node's cell, otherwise it's its first editable cell.

MPS has a feature which makes you able to set different selection policy. To do this, you should mark a meta cell with either Attracts Focus (F) or First Editable (FE) markers. You can set them both from inspector as well as using shortcuts Ctrl-Shift-F and Ctrl-Alt-Shift-F, respectively.

What do these markers mean? For example, let a node to navigate to is represented by a certain cell which is a collection. By default, MPS will look for the first editable leaf(i.e. not collection) cell. But if there's a cell generated from a meta cell marked with F, this marked cell will be selected. If that cell with F contains another cells with F inside it, the innermost leftmost cell with F will be selected. One can imagine that MPS builds a tree from all cells with focus policy, and then performs a DFS and returns the first leaf found. But if such DFS reaches a cell marked with FE in that tree, MPS does not go deeper but selects the first editable cell of the cell with FE.

Retrieved from "Focus_Policy.html"
Views