haiku-website/static/legacy-docs/bebook/BMenuItem_Overview.html

88 lines
10 KiB
HTML
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>The Be Book - System Overview - The Interface Kit</title><link rel="stylesheet" href="be_book.css" type="text/css" media="all" /><link rel="shortcut icon" type="image/vnd.microsoft.icon" href="./images/favicon.ico" /><!--[if IE]>
<link rel="stylesheet" type="text/css" href="be_book_ie.css" />
<![endif]--><meta name="generator" content="DocBook XSL Stylesheets V1.73.2" /><meta name="keywords" content="Access, BeOS, BeBook, API" /><link rel="start" href="index.html" title="The Be Book" /><link rel="up" href="TheInterfaceKit_Overview.html" title="The Interface Kit" /><link rel="prev" href="BMenuField_Overview.html" title="BMenuField" /><link rel="next" href="BOutlineListView_Overview.html" title="BOutlineListView" /></head><body><div id="header"><div id="headerT"><div id="headerTL"><a accesskey="p" href="BMenuField_Overview.html" title="BMenuField"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a accesskey="u" href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a accesskey="n" href="BOutlineListView_Overview.html" title="BOutlineListView"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="headerTR"><div id="navigpeople"><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div><div class="navigboxed" id="navigindex"><a accesskey="i" href="ClassIndex.html" title="Index">I</a></div><div class="navigboxed" id="naviglang" title="English">en</div></div><div id="headerTC">The Be Book - System Overview - The Interface Kit</div></div><div id="headerB">Prev: <a href="BMenuField_Overview.html">BMenuField</a>  Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a>  Next: <a href="BOutlineListView_Overview.html">BOutlineListView</a></div><hr /></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><div xmlns:d="http://docbook.org/ns/docbook"><h2 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenuItem_Overview"></a>BMenuItem</h2></div></div></div><a id="id551096" class="indexterm"></a><p>
A <a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>
object displays one item within a menu and contains the state
associated with that item. By default, menu items display text; a derived
class can reimplement the
<a class="link" href="BMenuItem.html#BMenuItem_Draw" title="Draw(), DrawContent()"><code class="methodname">Draw()</code></a> and
<a class="link" href="BMenuItem.html#BMenuItem_DrawContent"><code class="methodname">DrawContent()</code></a>
hook functions to draw something else.
</p><p>
Each <a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a>
object can have its own invocation message and target. A
menu item needn't send any message—it can be used simply for its
visual presence (see
<a class="link" href="BSeparatorItem.html" title="BSeparatorItem"><code class="classname">BSeparatorItem</code></a>
for an example).
</p><p>
Menu items can't be used outside of a menu; to add a
<a class="link" href="BMenuItem.html" title="BMenuItem"><code class="classname">BMenuItem</code></a> to a
<a class="link" href="BMenu.html" title="BMenu"><code class="classname">BMenu</code></a>, call
<a class="link" href="BMenu.html#BMenu_AddItem" title="AddItem()"><code class="methodname">BMenu::AddItem()</code></a>.
</p><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id551187"></a>Kinds of Items</h3></div></div></div><p>
Some menu items set up the menu hierarchy by giving users access to
submenus. A submenu remains hidden until the user operates the item that
controls it.
</p><p>
Other items accomplish specific actions. When the user invokes the item,
it sends a message to a target
<a class="link" href="BLooper.html" title="BLooper"><code class="classname">BLooper</code></a> and
<a class="link" href="BHandler.html" title="BHandler"><code class="classname">BHandler</code></a>,
usually the window where the menu at the root of the hierarchy (a
<a class="link" href="BMenuBar.html" title="BMenuBar"><code class="classname">BMenuBar</code></a> object) is
displayed. The action that the item initiates, or the state that it sets,
depends entirely on the message and the target's response to it.
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="BMenuItem_Overview_ShortcutsAndTriggers"></a>Shortcuts and Triggers</h3></div></div></div><p>
Any menu item (except for those that control submenus) can be associated
with a keyboard shortcut, a character the user can type in combination
with a <span class="keycap">Command</span> key (and possibly other modifiers) to invoke the item. The
shortcut character is displayed in the item to the right of the label.
</p><p>
A shortcut works even when the item it invokes isn't visible on-screen.
It, therefore, has to be unique within the window (within the entire menu
hierarchy).
</p><p>
Every menu item is also associated with a trigger, a character that the
user can type (without the <span class="keycap">Command</span> key) to invoke the item. The trigger
works only while the menu is both open on-screen and can be operated
using the keyboard. It therefore must be unique only within a particular
branch of the menu hierarchy (within the menu).
</p><p>
The trigger is one of the characters that's displayed within the
item—either the keyboard shortcut or a character in the label. When
it's possible for the trigger to invoke the item, the character is
underlined. Like shortcuts, triggers are case-insensitive.
</p><p>
For an item to have a keyboard shortcut, the application must explicitly
assign one. However, by default, the Interface Kit chooses and assigns
triggers for all items. The default choice can be altered by the
<a class="link" href="BMenuItem.html#BMenuItem_SetTrigger" title="SetTrigger(), Trigger()"><code class="methodname">SetTrigger()</code></a>
function.
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id551294"></a>Marked Items</h3></div></div></div><p>
An item can also be marked (with a check mark drawn to the left of the
label) in order to indicate that the state it sets is currently in
effect. Items are marked by the
<a class="link" href="BMenuItem.html#BMenuItem_SetMarked" title="SetMarked(), IsMarked()"><code class="methodname">SetMarked()</code></a>
function. A menu can be set up so that items are automatically
marked when they're selected and exactly one item is marked at all times.
(See <a class="link" href="BMenu.html#BMenu_SetRadioMode" title="SetRadioMode(), IsRadioMode()"><code class="methodname">SetRadioMode()</code></a> in the
<a class="link" href="BMenu.html" title="BMenu"><code class="classname">BMenu</code></a>
class.)
</p></div><div class="section"><div xmlns="" xmlns:d="http://docbook.org/ns/docbook" class="titlepage"><div><hr /><div xmlns:d="http://docbook.org/ns/docbook"><h3 xmlns="http://www.w3.org/1999/xhtml" class="title"><a id="id551331"></a>Disabled Items</h3></div></div></div><p>
Items can also be enabled or disabled (by the
<a class="link" href="BMenuItem.html#BMenuItem_SetEnabled" title="SetEnabled(), IsEnabled()"><code class="methodname">SetEnabled()</code></a> function). A
disabled item is drawn in muted tones to indicate that it doesn't work.
It can't be selected or invoked. If the item controls a specific action,
it won't post the message that initiates the action. If it controls a
submenu, it will still bring the submenu to the screen, but all the items
in submenu will be disabled. If an item in the submenu brings its own
submenu to the screen, items in that submenu will also be disabled.
Disabling the superitem for a submenu in effect disables a whole branch
of the menu hierarchy.
</p></div></div><div id="footer"><hr /><div id="footerT">Prev: <a href="BMenuField_Overview.html">BMenuField</a>  Up: <a href="TheInterfaceKit_Overview.html">The Interface Kit</a>  Next: <a href="BOutlineListView_Overview.html">BOutlineListView</a> </div><div id="footerB"><div id="footerBL"><a href="BMenuField_Overview.html" title="BMenuField"><img src="./images/navigation/prev.png" alt="Prev" /></a> <a href="TheInterfaceKit_Overview.html" title="The Interface Kit"><img src="./images/navigation/up.png" alt="Up" /></a> <a href="BOutlineListView_Overview.html" title="BOutlineListView"><img src="./images/navigation/next.png" alt="Next" /></a></div><div id="footerBR"><div><a href="http://www.haiku-os.org"><img src="./images/People_24.png" alt="haiku-os.org" title="Visit The Haiku Website" /></a></div><div class="navighome" title="Home"><a accesskey="h" href="index.html"><img src="./images/navigation/home.png" alt="Home" /></a></div></div><div id="footerBC"><a href="http://www.access-company.com/home.html" title="ACCESS Co."><img alt="Access Company" src="./images/access_logo.png" /></a></div></div></div><div id="licenseFooter"><div id="licenseFooterBL"><a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/" title="Creative Commons License"><img alt="Creative Commons License" style="border-width:0" src="https://licensebuttons.net/l/by-nc-nd/3.0/88x31.png" /></a></div><div id="licenseFooterBR"><a href="./LegalNotice.html">Legal Notice</a></div><div id="licenseFooterBC"><span id="licenseText">This work is licensed under a
<a rel="license" href="http://creativecommons.org/licenses/by-nc-nd/3.0/">Creative
Commons Attribution-Non commercial-No Derivative Works 3.0 License</a>.</span></div></div></body></html>