Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 4.0
Wiki Markup
{alias:qdestroyed}
h2. Name

*qdestroyed* — catch widget destruction

h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}

*qdestroyed* \[_widget_] _cmds_ 

{panel}

h2. Description

The *qdestroyed* command allows one to catch the destruction of widgets. The programmer can assign Tcl commands to be executed immediately before the destruction of the widget. This is useful for cleanup actions. Unlike a closeevent (see [qcloseevent]) the destruction process can not be halted. 

A widget can be deleted in several ways. A widget will always be deleted if it's parent is deleted. It will also be deleted when closing if the [deleteonclose|qsetattribute] attribute is set. A widget can be deleted directly using the [qdelete] command. 

Deleting a widget is not the same as closing it. Closing in itself just renders the widget invisible, while still retaining the widget in the computers memory for later redisplay. Deleting a widget removes the widget entirely from memory, requiring that the widget be re-created in order to be redisplayed. A widget is always closed before it is deleted. 

h2. Arguments
_widget_
{indent}The widget for which we want to catch the destruction event. This can be any widget or qaction .
{indent}
_cmds_
{indent}Tcl statements to be executed when the widget is destructed. This will often be the name of a Tcl procedure. The widget's children are destroyed immediately after these commands are processed. 
{indent} 

h2. Examples

h3. Ex.1: Catching a destruct event
{anchor:Catching a destruct event}

{noformat:|borderWidth=1|bgColor=#eeeeee}

Name

qdestroyed — catch widget destruction

Syntax

Panel
bgColor#FFFFAA
borderWidth1
borderStylesolid

qdestroyed [widget] cmds

Description

The qdestroyed command allows one to catch the destruction of widgets. The programmer can assign Tcl commands to be executed immediately before the destruction of the widget. This is useful for cleanup actions. Unlike a closeevent (see qcloseevent) the destruction process can not be halted.

A widget can be deleted in several ways. A widget will always be deleted if it's parent is deleted. It will also be deleted when closing if the deleteonclose attribute is set. A widget can be deleted directly using the qdelete command.

Deleting a widget is not the same as closing it. Closing in itself just renders the widget invisible, while still retaining the widget in the computers memory for later redisplay. Deleting a widget removes the widget entirely from memory, requiring that the widget be re-created in order to be redisplayed. A widget is always closed before it is deleted.

Arguments

widget

cmds

Examples

Ex.1: Catching a destruct event

Anchor
Catching a destruct event
Catching a destruct event

No Format
bgColor#eeeeee
borderWidth1
#
# Procedure to be called when the widget is destructing.
#

proc killed {} {
  puts "Object destroyed"
}

set w [qwidget]

# This is needed for the widget to be deleted when closing
qsetattribute $w deleteonclose

# Assign the 'killed' procedure as destruction-callback
qdestroyed $w killed

qshow $w

{noformat}

Example +Catching a destruct event+ shows the procedure 

Example Catching a destruct event shows the procedure 'killed'

...

assigned

...

as

...

a

...

callback

...

function

...

to

...

be

...

called

...

when

...

the

...

window

...

'w'

...

is

...

destructed.

...