23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Command Menus<br />

The next aspect of an app bar we need to explore in a little more depth are those commands whose<br />

type property is set to flyout. In this case the command’s flyout property must identify a<br />

WinJS.UI.Flyout object or a WinJS.UI.Menu control (which is a flyout). As noted before, flyout or popup<br />

menus like this are used when there are too many related commands cluttering up the basic app bar, or<br />

when you need other types of controls that aren’t quite appropriate on the app bar itself. It’s said,<br />

though, that if you’re tempted to use a button labeled “More”, “Advanced”, or “Other Stuff” because<br />

you can’t figure out how to organize the commands otherwise, it’s a good sign that the app itself is too<br />

complex! Seek ways to simplify the app’s purpose so that the app bar doesn’t just become a repository<br />

for randomness.<br />

We’ll be covering flyouts more fully a little later in this chapter, but let’s see how to use one in an app<br />

bar, as demonstrated in Scenario 6 of the <strong>HTML</strong> flyout control sample (not the app bar sample, mind<br />

you!):<br />

In html/appbar-flyout.html of this sample we see the app bar button declared as follows:<br />

<br />

The respondFlyout element identified here is defined earlier in html/appbar-flyout.html; note that<br />

such an element must be declared prior to the app bar to make sure it’s instantiated before the app bar<br />

is created:<br />

<br />

<br />

<br />

<br />

<br />

<br />

<br />

290

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!