[ Pobierz całość w formacie PDF ]
.Actions serve two functions: (1) they representproperties common to the user interface elements, such as whether a control isenabled or checked, and (2) they respond when a control fires, for example, when theapplication user clicks a button or chooses a menu item.You can create a repertoireof actions that are available to your application through menus, through buttons,through toolbars, context menus, and so on.Actions are associated with other components:" Clients: One or more clients use the action.The client most often represents amenu item or a button (for example, TToolButton, TSpeedButton, TMenuItem,TButton, TCheckBox, TRadioButton, and so on).Actions also reside on ActionBandcomponents such as TActionMainMenuBar and TActionToolBar.When the clientreceives a user command (such as a mouse click), it initiates an associated action.Typically, a client s OnClick event is associated with its action s OnExecute event." Target: The action acts on the target.The target is usually a control, such as amemo or a data control.Component writers can create actions specific to the needsof the controls they design and use, and then package those units to create moremodular applications.Not all actions use a target.For example, the standard helpactions ignore the target and simply launch the help system.A target can also be a component.For example, data controls change the target toan associated dataset.Devel opi ng t he appl i c at i on user i nt er f ac e 9-19Or g a n i z i n g a c t i o n s f o r t o o l b a r s a n d me n u sThe client influences the action the action responds when a client fires the action.The action also influences the client action properties dynamically update the clientproperties.For example, if at runtime an action is disabled (by setting its Enabledproperty to False), every client of that action is disabled, appearing grayed.You can add, delete, and rearrange actions using the Action Manager or the ActionList editor (displayed by double-clicking an action list object, TActionList).Theseactions are later connected to client controls.Setting up action bandsBecause actions do not maintain any layout (either appearance or positional)information, Delphi provides action bands which are capable of storing this data.Action bands provide a mechanism that allows you to specify layout information anda set of controls.You can render actions as UI elements such as toolbars and menus.You organize sets of actions using the Action Manager (TActionManager).You canuse standard actions provided or create new actions of your own.You then create the action bands:" Use TActionMainMenuBar to create a main menu." Use TActionToolBar to create a toolbar.The action bands act as containers that hold and render sets of actions.You can dragand drop items from the Action Manager editor onto the action band at design time.At runtime, application users can also customize the application s menus or toolbarsusing a dialog box similar to the Action Manager editor.Creating toolbars and menusNote This section describes the recommended method for creating menus and toolbars inWindows applications.For cross-platform development, you need to use TToolBarand the menu components, such as TMainMenu, organizing them using action lists(TActionList).See Setting up action lists on page 9-26.You use the Action Manager to automatically generate toolbars and main menusbased on the actions contained in your application.The Action Manager managesstandard actions and any custom actions that you have written.You then create UIelements based on these actions and use action bands to render the actions items aseither menu items or as buttons on a toolbar.The general procedure for creating menus, toolbars, and other action bands involvesthese steps:" Drop an Action Manager onto a form." Add actions to the Action Manager, which organizes them into appropriate actionlists." Create the action bands (that is, the menu or the toolbar) for the user interface." Drag and drop the actions into the application interface.9-20 Devel oper s Gui deOr g a n i z i n g a c t i o n s f o r t o o l b a r s a n d me n u sThe following procedure explains these steps in more detail [ Pobierz całość w formacie PDF ]