Accessing the current selection

The Presentation framework uses the GUI bundle to maintain and provide access to the current selection. The framework creates an initial current selection on a document by calling the model's CreateSelection function. Subsequently, you can change the current selection with the MGUIBundle function AdoptCurrentModelSelection. The Presentation framework notifies the view whenever AdoptCurrentModelSelection function is called, so the view always reflects the current selection. The Presentation framework also ensures that the current selection is updated whenever a command is executed that modifies the current selection.

To access the current selection for a document, you can use the MGUIBundle function GetCurrentModelSelection.This function returns Nil if the current selection has not been defined or is on another document component.

Because GetCurrentModelSelection returns a pointer to the base selection class, it is a good idea to provide a function that downcasts the returned selection to the selection class for your model. TTilesView provides such a convenience function, GetTilesSelection. This function calls the MGUIBundle function GetCurrentModelSelection and downcasts the result to a pointer to a TTilesSelection. It returns 0 if there is no current selection on the Tiles model, so you should verify the returned pointer before using it.



[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker