focus

(#<widget> 'focus)
returns the id for the item that currently has the focus, or an empty string if no item has the focus.
(#<widget> 'focus tagOrId)
Set the keyboard focus for the canvas widget to the item given by tagOrId.

If tagOrId refers to several items, then the focus is set to the first such item in the display list that supports the insertion cursor.

If tagOrId doesn't refer to any items, or if none of them support the insertion cursor, then the focus isn't changed.

If tagOrId is (), then the focus item is reset so that no item has the focus.

Once the focus has been set to an item, the item will display the insertion cursor and all keyboard events will be directed to that item. The focus item within a canvas and the focus window on the screen (set with the focus command) are totally independent: a given item doesn't actually have the input focus unless (a) its canvas is the focus window and (b) the item is the focus item within the canvas.

In most cases it is advisable to follow the focus widget command with the focus command to set the focus window to the canvas (if it wasn't there already).


© Author | Home | Sitemap