Tool Windows

You know a tool window when you see one. It’s basically a helper window that you want to keep around while you perform a task in the IDE. You could think of a tool window as a glorified modeless dialog box (meaning you can click other UI elements outside of the window) with additional functionality that makes it a tool window, such as the ability to dock and autohide.

At a high level, a tool window can be in one of five states: dockable, autohiding, tabbed document, floating, or hidden. These states can be combined and put into special cases to cause the tool window to be in interesting hybrid states, as illustrated in Tip 4.16: You can use docking targets to dock tool windows in new and crazy ways. But for now, we’ll explore the most common of these states.

Dockable State

Prior to Visual Studio 2005, it took some trial and error to dock a tool window where you wanted it. The Visual Studio team would watch usability studies of users trying to complete a task, where the user would be just mere pixels away from docking his tool window successfully but never quite make it. Many of us would nearly fall out of our chairs trying to mentally push the user’s mouse pointer to the correct location.

Fortunately, Visual Studio 2005 introduced docking targets, which not only provide a bird’seye view of what dock positions are available, but also provides a preview of where the tool window will be docked. No more falling out of our chairs.

Tip 4.13: You can choose from nine IDE tool window docking targets

When a tool window is in a dockable state, a set of docking targets appears when you move a tool window to a specific location, such as hovering it over another tool window.

But did you know that there are nine IDE docking targets? These docking targets allow you to pin tool windows to the inner and outer parts of the IDE itself.

Tip 4.13: You can choose from nine IDE tool window docking targets

Docking target 1 puts a tool window into a tabbed document state, docking target 3 docks a tool window to the inner right edge, and docking target 7 docks a tool window to the outer right edge.

If there’s no tool window docked on the right, targets 7 and 3 seem to be the same. But if you dock tool window A using target 7 and then dock tool window B using target 3, you get tool window A on the outside and tool window B docked to the left side of tool window A.

You have no idea how crazy it was to test all of these combinations! But I loved it nonetheless.

Tip 4.14: How to undock only a single tool window from a group

You can always undock a single tool window by dragging its tool window tab.

Tip 4.14: How to undock only a single tool window from a group

Tip 4.15: You can dock a tool window to the top of the IDE

I implied this possibility existed in a previous tip when I introduced all the various IDE docking targets (see Tip 4.13: You can choose from nine IDE tool window docking targets). But I wanted to call it out specifically since it is rare to see a tool window in this position.

Tip 4.15: You can dock a tool window to the top of the IDE

The Memory tool windows (when you’re in debugging mode) are the only ones that come to mind right now. But there’s nothing preventing you from docking your own tool windows up there, as illustrated with the Solution Explorer in the preceding screen shot.

Tip 4.16: You can use docking targets to dock tool windows in new and crazy ways

When you drag a tool window over a docking target, you’ll get a preview, as you see in the next screen shot.

Sara Aside

But, let’s have a little fun ...

I have no idea how the tool window tab group shown next could be useful, but maybe if it were resized to fit a secondary monitor ...

Sara Aside

Can you tell I enjoyed being a tester?

Autohiding State

Sometimes you don’t want to completely close a tool window, but you don’t want it in your way. Autohiding is a nice way of tucking the tool window away but keeping it ready to spring back out whenever the IDE thinks you need it, or whenever you want it to slide back out.

Tip 4.17: You can autohide all of your tool windows with one command

On the Window menu, there’s the Auto Hide All command. Your environment can go from looking like the following screen shot, with lots and lots of tool windows open:

Tip 4.17: You can autohide all of your tool windows with one command

to looking like this screen shot:

Tip 4.17: You can autohide all of your tool windows with one command

However, there is one caveat: there isn’t a command to slide out all of your tool windows.

Tip 4.18: You can customize how pressing a tool window push pin autohides the tool window or tool window tab group

On the Tools–Options–Environment–General page, you’ll find the Auto Hide Button Affects Active Tool Window Only option. The next illustration is a snapshot of two tool windows docked together with the Auto Hide push pin circled.

Tip 4.18: You can customize how pressing a tool window push pin autohides the tool window or tool window tab group

If you want autohide to apply only to Solution Explorer when you click the push pin, enable the option. Otherwise, autohide will apply to both tool windows.

Tip 4.19: You can show autohiding tool windows via the tool window autohide channel

This is one of those features I always forget. The window management developer and I were discussing another tip, when he showed me the autohide channel context menu.

Right-click the tool window autohide channel to invoke the context menu, and click one of the tool windows to slide it out from hiding.

Note in the picture that the Solution Explorer and Class View tabs are side by side, whereas the Properties tab has some space separating it from the other tabs. This is because Solution Explorer and Class View are docked together and the Properties browser is docked next to it, along the edge.

Tip 4.19: You can show autohiding tool windows via the tool window autohide channel

Tip 4.20: You can double-click the tool window title bar to redock the tool window

After you drag a tool window to an undocked position, you can quickly redock the tool window to the previous location by double-clicking the title bar.

Tip 4.20: You can double-click the tool window title bar to redock the tool window

Also, you may notice some tool windows are in tool window groups (as shown in the following image), whereas others are docked individually. To separate a tool window from its group, either drag away or double-click the tool window tab, as shown in the following screen shot.

Tip 4.20: You can double-click the tool window title bar to redock the tool window

Tip 4.21: You can use Shift+Click to automatically dock an autohiding tool window

Let’s start with "Tool Window 101" training. When a tool window is docked (as discussed in Tip 4.13: You can choose from nine IDE tool window docking targets), you have the option to autohide. Just click the autohide push pin as shown in the following image. Or go to the Window menu and choose Auto Hide to autohide the currently selected tool window.

Sara Aside

Clicking this push pin causes the window to autohide, as shown here:

Sara Aside

You can mouse over the Solution Explorer and click the push pin again to redock. Or you can go to the Window menu and choose Auto Hide, which unchecks the Auto Hide setting. But what’s the fun in that?

Now for the actual tip. Did you know that you can press Shift+Click on the autohiding tool window (the second picture in this tip) to move it into a docked state?

However, if the tool window is already sliding out (as shown in the next screen shot), it is automatically hidden.

Sara Aside

So you are probably wondering, "Okay Sara, so what is Shift+Click really supposed to do?" It is supposed to perform a Window.Hide command. But when the tool window starts to slide, stuff happens in the IDE and it goes into a docked state instead of a hide state.

More than you ever wanted to know about the Visual Studio environment, huh?

Tip 4.22: You can speed up or slow down how fast a tool window slides out from a docked position

On the Tools–Options–Environment–General page, you’ll find the Animate Environment Tools check box. This option controls the speed at which a tool window slides in and out of an autohide state.

Tip 4.22: You can speed up or slow down how fast a tool window slides out from a docked position

Additionally, you can opt out completely from the animation effect by unchecking the Animate Environment Tools check box. If you do that, tool windows pop to their new locations rather than sliding to them.

Floating State

Floating is very similar to the dockable state, with the exception that docking targets never appear for a tool window that is in a floating state. In the General Development Settings, the Find And Replace window is in a floating state. I’ve seen questions about how to dock the tool window. To do so, the Find And Replace window must first be put in a dockable state.

Tip 4.23: Why would you want to make a tool window float?

Recall from earlier in this chapter how tool windows are available in five different states:

  • Floating

  • Dockable

  • Tabbed document

  • Auto Hide

  • Hide

I would say that the dockable state actually represents two mutually exclusive positions the tool window can be in:

  • Docked. The tool window is locked to a specific location, usually to the side of the IDE.

  • Hovering. This is my made-up term to describe a tool window that is in the dockable state but is not docked. Recall that the dockable state is different from a floating state, because the floating state cannot be docked.

Most of these states are self-explanatory, especially after a little bit of trial and error, but the floating state may be less obvious. In a floating state, the tool window hovers over the IDE but cannot be docked to a fixed position in the IDE.

Hovering

How is this useful? Sometimes you just want to position a tool window in a certain area and, unfortunately, the dock targets appear. If you set it to Floating, you never get docking targets for the tool window. (See Tip 4.13: You can choose from nine IDE tool window docking targets.)

Tabbed Document State

A tool window in a tabbed document state will appear in the file tab channel. I found this behavior most useful with the Output window, as it maximizes the tool window, allowing for the largest amount of text to appear on the screen at one time.

Tip 4.24: How to use Tabbed Document to maximize a tool window

Tip 4.24: How to use Tabbed Document to maximize a tool window

Yet another one of those "Wow, I didn’t know you could do that until someone showed me" moments happened when I found out you can maximize a tool window by setting it to a tabbed document state. With your desired tool window selected, either right-click the tool window title bar or tab window to bring up the tool window context menu and then select Tabbed Document. Alternatively, you can go to the Window menu and select Tabbed Document.

Tip 4.24: How to use Tabbed Document to maximize a tool window

Keyboard Navigation

There are keyboard shortcuts for navigating among the various tool windows opened in your IDE. All the keyboard shortcuts are customizable on the Tools-Options–Environment–Keyboard page.

Tip 4.25: You can use Alt+F7 and Alt+Shift+F7 to move to the next and previous tool windows

The tool windows you open and visit are saved in an MRU (most-recently used) list. So you can navigate among all the various opened tool windows, using Alt+F7 for next and Alt+Shift+F7 for previous.

Tip 4.25: You can use Alt+F7 and Alt+Shift+F7 to move to the next and previous tool windows

Tip 4.26: You can use Alt+F6 and Alt+Shift+F6 to cycle through opened tool windows

If you don’t want the IDE Navigator to appear when you navigate among various opened tool windows, use Alt+F6 and Alt+Shift+F6 to go to the next and previous tool windows, respectively, in most-recently used sort order.

Tip 4.26: You can use Alt+F6 and Alt+Shift+F6 to cycle through opened tool windows

Tip 4.27: How to use Ctrl+Page Up and Ctrl+Page Down to navigate among all the tool windows in a tool window group

Whenever tool window tabs are docked together, they form a little group that you can move around and such, as you’ve seen in previous tips.

Tip 4.27: How to use Ctrl+Page Up and Ctrl+Page Down to navigate among all the tool windows in a tool window group

You can use Ctrl+Page Up and Ctrl+Page Down to navigate among the tool windows in this group.

Hide State

A tool window can be in a hidden state, also known as a closed state, by either clicking the X on the tool window title bar, or by selecting Window–Hide.

Tip 4.28: How to customize what clicking the X button does to a tool window or tool window tab group

On the Tools–Options–Environment–General page, you’ll find the Close Button Affects Active Tool Window Only check box. The following screen shot shows a snapshot of two tool window tabs docked together, with the close button circled.

Tip 4.28: How to customize what clicking the X button does to a tool window or tool window tab group

If you want only Solution Explorer to close when pressing the X button, enable the option. Otherwise, both tool windows will close.

Hidden Keyboard Shortcuts

I call these "hidden keyboard shortcuts" because the keyboard shortcuts are not bound to a command, meaning you will never find them on the Tools–Options–Environment–Keyboard page. The only way you would find them is if someone told you about them.

I’ve made an exception for Shift+Esc and included it in this list because I don’t think it is very well known, and I’m always shocked whenever I’m reminded about it. I always think it’s one of these hidden keyboard shortcuts, but then I realize it’s bound to a command.

Tip 4.29: How to drag a tool window around using the keyboard

With the desired tool window selected, press Alt+Minus to bring up the tool window menu. Press the Down Arrow to select the Move command, and press Enter. Now you can control the tool window with the arrow keys.

Tip 4.29: How to drag a tool window around using the keyboard

To dock, simply use the arrow keys to get to the desired dock target and hit Enter to commit to docking the tool window to the new location.

Tip 4.30: How to resize a tool window from the keyboard

When a tool window is not docked, follow these steps to resize the window using the keyboard:

  1. Press Alt once.

  2. Press the Spacebar once. You will get the standard window system menu with Move and Size.

    Tip 4.30: How to resize a tool window from the keyboard
  3. Select Size.

  4. Press the arrow keys toward the window edge you want to resize, and resize from there.

  5. Press Enter to commit to the resizing, or press Esc to cancel the resize changes.

If you press Alt+Spacebar, you get the main Visual Studio window system menu; this is why you must release the Alt key before you press the Spacebar.

Tip 4.31: How to access a toolbar within a tool window

You may have noticed that within tool windows such as the Solution Explorer, you cannot reach the toolbar by hitting Tab or using the arrow keys. The keyboard shortcut to reach a tool window’s toolbar is Shift+Alt. Note that Alt+Shift will not work.

Tip 4.31: How to access a toolbar within a tool window

Tip 4.32: You can use Shift+Esc to close a tool window

As I’ve said time and time again on my blog, it’s really the simple things in life.... I keep forgetting about this tip, until I see this keyboard shortcut and have to look up what it does.

Use Shift+Esc to close the currently selected tool window. If the focus is not on a tool window but in an editor, and you press Shift+Esc, Visual Studio will just look at you.

Tip 4.32: You can use Shift+Esc to close a tool window
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.147.71.94