Wiki Markup |
---|
{alias:qcloseevent}
h2. Name
*qcloseevent* — catch close events
h2. Syntax
{panel:|borderStyle=solid|borderWidth=1|bgColor=#FFFFAA}
*qcloseevent* \[_widget_] _cmds_
{panel}
h2. Description
The *qcloseevent* command allows one to catch the closing of windows (qwidgets and qmainwindows). The programmer can assign Tcl commands to be executed during the closing of the window, useful for cleanup actions or for cancelling the close event.
h2. Arguments
_widget_
{indent}The window for which we want to catch the close event. This has to be [qwidget] or [qmainwindow].
{indent}
_cmds_
{indent}Tcl statements to be executed when the window closes. This will often be the name of a Tcl procedure. If the procedure returns the string 'ignore' the event is cancelled, and the window will remain visible.
{indent}
h2. Examples
h3. Ex.1: Catching a close event
{anchor:Catching a close event}
{noformat:|borderWidth=1|bgColor=#eeeeee} |
Name
qcloseevent — catch close events
Syntax
Panel | ||||||
---|---|---|---|---|---|---|
| ||||||
qcloseevent [widget] cmds |
Description
The qcloseevent command allows one to catch the closing of windows (qwidgets and qmainwindows). The programmer can assign Tcl commands to be executed during the closing of the window, useful for cleanup actions or for cancelling the close event.
Arguments
widget
cmds
Examples
Ex.1: Catching a close event
Anchor | ||||
---|---|---|---|---|
|
No Format | ||||
---|---|---|---|---|
| ||||
# Callback procedure for closeevent
proc ce {} {
puts "Closing"
set button [qinformation "Closing Window" "Really close window?" OK Cancel]
if { $button == 1 } { ; # cancel
return ignore
}
}
set w [qwidget ]
# Call 'ce' when closing
qcloseevent $w ce
qshow $w
{noformat}
Example +Catching a close event+ shows the procedure |
Example Catching a close event shows the procedure 'ce'
...
assigned
...
as
...
a
...
callback
...
function
...
to
...
be
...
called
...
when
...
the
...
window
...
'w'
...
is
...
closed.
...
The
...
user
...
is
...
then
...
asked
...
whether
...
he
...
wants
...
the
...
window
...
closed
...
or
...
not.
...
Note
...
that
...
not
...
providing
...
a
...
return
...
value
...
in
...
the
...
proc
...
will
...
accept
...
the
...
event.
...