selected-object

Generic Function

Package: common-graphics

Arguments: window

Returns an object or a list of objects that are considered to be selected in window and which may be acted upon by arbitrary (typically menu) commands. In the development environment, menu commands typically act upon the selected-object of the window that currently has the keyboard focus. Methods can be added on this generic function to return appropriate objects for specialized classes of windows, though the default behavior will often suffice. If no object is selected, this function returns nil.

If text is selected, that text is returned as a string. If other objects are selected (controls on a form, for example), a list of selected objects is returned.

Note: this function will return true both when an object is selected and highlighted (e.g. text which is highlighted after the left mouse button is depressed and dragged over the text) and when the cursor is within text but no text is highlighted. Thus, if the cursor is between the f and the first o of foo, foo will be returned by selected-object even though no text is highlighted. While some menu commands work on objects selected by the second definition (cursor in the text but no text highlighted), others, Cut for example, do not work in that case. The function get-selectionget-selection returns two integers indicating the beginning and the end of highlighted text. If the two values returned by that function are equal, no text is highlighted and commands that only work on highlighted text should not be invoked.

Programmers may wish to make menu-items that only work on highlighted text unavailable if no text is highlighted when the menu is shown. The generic function about-to-show-menuabout-to-show-menu is called just prior to a menu being displayed and is designed to allow menu-items to be made available or unavailable based the current state. Programmers can subclass menu and write methods on about-to-show-menuabout-to-show-menu to achieve the desired behavior, such as making Copy unavailable if selected-object returns nil and Cut unavailable when selected-object returns true but get-selectionget-selection indicates there is no highlighted text.

Common Graphics and IDE documentation is described in About Common Graphics and IDE documentation in cgide.htm.

The documentation is described in introduction.htm and the index is in index.htm.

Copyright (c) 1998-2000, Franz Inc. Berkeley, CA., USA. All rights reserved.

Created 2000.10.5.