The Presentation framework provides a class template for command bindings, TGUIDocumentComponentCommandBindingTo<ATarget>. This template lets you easily create a class to use as a binding for any command you create. To bind a TChangeColorCommand to a TTilesSelection, the Tiles program uses an instance of TGUIDocumentComponentCommandBindingTo<TTilesSelection>, named TTilesCommandBinding by a typedef
statement in the code.
NOTE TGUIDocumentComponentCommandBindingTo<ATarget> also provides a parameter that lets you control the label for the Undo/Redo menu item. In the current release, undo/redo labels do not appear in the presentation. In a later release, when the framework supports undo/redo labels, you could set a label to "Set to Red", and the undo/redo labels would read "Undo Set to Red" and "Redo Set to Red".
This diagram shows how the binding connects a command and its target selection:
You can compile and run the Tiles project in the directory $TaligentRoot/TaligentSamples/Supported/Apps/TilesTutorial/03.CommandsAndSelections/Tiles
and launch a Tiles document using TilesTutorialApp
to see the functionality. Make sure that a previous version of a Tiles document is not running when you compile this version. When you click on a tile, the color of that tile will change. See "Launching a document" on page 21 for directions on how to compile a project and launch a document.