![]() |
|
Menus and PopupsThis tutorial assumes you are familiar with the basic buildup of SiteFusion applications, as described in previous tutorials.The MenubarMenus are handled very differently between platforms. Windows and generally Linux too show menubars inside the window, while Mac has a system menubar that contains the menu of the active application and window:![]() XUL provides the menubar element, which translates the menu elements underneith it to the native representations of the operating system. The menu element can contain a menupopup element, which in turn contains menuitem, menuseparator and possibly more menu elements. These elements are represented by the XULMenuBar, XULMenu, XULMenuPopup, XULMenuItem and XULMenuSeparator classes in PHP. For example, a simple menubar with two menus looks like this:
<?php ![]() ![]() In Mac OS X, some system default menu items will be added automatically, like this 'Special Characters' item in the Edit menu. The XULMenuItem constructor can take five parameters, all of them strings. Because of that, if you want to set one of these parameters in the constructor, make sure to supply the ones before it as empty strings:
<?php Menu items can also act as checkboxes or radio buttons, as shown above. This can also be done through the XULMenuItem::type() method which sets the type attribute on the element. The state of these menuitems can be set and retrieved through the XULMenuItem::checked() method. They yield themselves on the command event by default, so that you don't have to set yielding manually. Menulists![]()
<?php Context menus, popups and tooltips
A context menu is just like any other popup. Popups are represented by the XUL elements menupopup, panel and tooltip. A menupopup is a popup that holds menuitems, while a panel is a more general popup that holds any kind of content. A tooltip is the familiar yellow balloon that is used to explain certain features of an application. If you just want a simple text as a tooltip, you don't need the tooltip element. Just call Node::tooltiptext( $text ). Context menus, popups and tooltips are usually grouped inside a XULPopupSet element, although this is not mandatory anymore. To have these elements appear in the user interface, use the following methods:
|
|
All content is © 2009 by FrontDoor Media Group, is available under the Creative Commons Attribution-Share Alike 2.5 License and is maintained by the SiteFusion.org staff |