Share via


Context Priority

F1 and lookup keyword topics are displayed in the Dynamic Help window in order of the keyword priority. The context provider that keywords are associated with, and whether the keywords represent context or subcontext, determines the priority of F1 and lookup keywords in the active context collection. Attributes, on the other hand, are all assigned equivalent priority in the active context collection.

The following subjects are discussed in this topic:

  • Context priority for keywords

  • Subcontext priority for keywords

  • Attribute priority

Context Priority for Keywords

All F1 and lookup keywords are automatically assigned a priority in the active context collection. This priority depends on the context bag or IVsUserContext object that the keyword was collected from. The priority assigned the context bag is in turn determined by the context provider that the context bag is attached to. Context providers include tool windows, editors, hierarchies, and so on. The Visual Studio IDE automatically sets the context priority when the context bag is retrieved from the context provider, which is when the selection changes. For example, the context bag for a tool window is automatically assigned a priority of VSUC_Priority_WindowFrame, whereas the context for a hierarchy is assigned a priority of VSUC_Priority_Project. As shown in the VSUSERCONTEXTPRIORITY enumeration, the tool window priority corresponds to a numeric value of 700 and the hierarchy priority corresponds to a numeric value of 300. Therefore, in the active context collection, context from a tool window has higher priority than context from a hierarchy, which is typically a project. For a list of priority values, see the VSUSERCONTEXTPRIORITY enumeration.

Subcontext Priority for Keywords

Although the IDE automatically assigns the priority level for context bags, you must assign the priority level for subcontext bags. You set this level when you link the subcontext bag to the parent context bag by calling the AddSubcontext method. By using this method, you specify the subcontext bag in the pSubCtx parameter and then the priority in the lpriority parameter. For a list of potential lpriority values, see the VSUSERCONTEXTPRIORITY enumeration.

For example, command windows, which the user can access through the Other Windows on the View menu, have both a context bag for the command window and a subcontext bag for a command in the command window. The IDE assigns a priority of VSUC_Priority_WindowFrame to the command window, and you assign a priority of VSUC_Priority_ToolWndSel to the command, which is the subcontext.

Note

If you want the subcontext to have the same priority as the parent context, you must specify a value of VSUC_Pri_None.

Attribute Priority

All attributes in the active context collection are assigned equivalent priority. However, in instances where an F1 keyword corresponds to more than one topic, the context service prioritizes the potential matches according to whether the topic is attributed as a syntax or reference topic type. At any time, the context service uses the attributes present in the active context to filter the list of potential keyword topics returned from the information provider, which is the Help file. Any topics with attributes that conflict with those in the active context are filtered away and are not shown in the Dynamic Help window. Topics without attributes, but those that match the keyword, are not excluded from the Dynamic Help window; these topics are displayed in the Dynamic Help window.

F1 and lookup keyword topics are displayed in the Dynamic Help window in order of the keyword priority, and based on how many attributes match between the keyword's topic and those in the active context. Topics associated with ambient priority keywords, such as VSUC_Priority_Ambient, in the IDE are always listed last in the Dynamic Help window. For more information, see Dynamic Help Window Implementation.

See Also

Concepts

Active Context

Dynamic Help Window Implementation

Reference

VSUSERCONTEXTPRIORITY

AddSubcontext

Other Resources

About Context-Sensitive Help