| Ticket UUID: | 2082457 | |||
| Title: | Cursor is not restored with mega-widgets | |||
| Type: | Bug | Version: | None | |
| Submitter: | relaxmike | Created on: | 2008-08-29 13:46:08 | |
| Subsystem: | tklib :: cursor | Assigned To: | hobbs | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2009-04-25 05:04:17 | |
| Resolution: | Fixed | Closed By: | hobbs | |
| Closed on: | 2009-04-24 22:04:17 | |||
| Description: |
Hi,
Suppose that you want to manage the cursor of the megawidget ctext. The cursor is not correctly
restored, because of the delegation of the
configure on the sub-widgets.
The fix consists in updating the tree of
widgets, begining by the bottom,
instead of begining by the top, as in the
current implementation.
A modified implementation is suggested,
so that the previous versions are maintained.
In the given test case, you first propagate the watch cursor over the
widget tree, then restore back the original cursor.
set mytext [ctext .mytext]
set result {}
lappend result [.mytext cget -cursor]
::cursor::propagate . watch
lappend result [.mytext cget -cursor]
::cursor::restore .
lappend result [.mytext cget -cursor]
destroy $mytext
set result $result
The expected result would be "xterm watch xterm".
The computed result is "xterm watch watch",
that is, the cursor is not correctly restored
on the ctext widget. The reason is the
following.
The widget .mytext cursor is backed up
into the CURSOR variable, and the configure
method is used to update the cursor :
set CURSOR(.mytext) xterm
.mytext config -cursor watch
At that point the instance command in the
ctext mega-widget delegates to the underlying
text widget :
.mytext._t configure -cursor watch
The cursor package then propagates the configure
down to the children widgets, begining
by the linemap :
set CURSOR(.mytext.l) xterm
.mytext.l config -cursor watch
When it comes to the underlying text, the
backup variable is set to the wrong cursor value,
because it has allready been updated to the
"watch" state :
set CURSOR(.mytext.t) watch
.mytext.t config -cursor watch
.mytext._t configure -cursor watch
When the restore command is called, the
widget .mytext is correctly updated :
::cursor::restore .mytext
.mytext config -cursor xterm
By delegation, it triggers the configure
method on the .mytext._t sub-widget :
.mytext._t configure -cursor xterm
Instead, when it comes to the sub-widget directly,
the watch cursor is configured :
::cursor::restore .mytext.t
.mytext.t config -cursor watch
.mytext._t configure -cursor watch
The fix simply consists in restoring children first.
This is done by implementing unpositionnal
arguments and maintaining the previous interface
with a special processing of options.
See in the attachment for a test-case and
a suggested modified version of cursor.tcl.
Regards,
Michaƫl
| |||
| User Comments: |
hobbs added on 2009-04-25 05:04:17:
allow_comments - 1 Applied simpler patch but with same point. Fixed with cursor 0.3. relaxmike added on 2008-09-11 21:06:33: File Added - 293019: testcursor.test File Added: testcursor.test relaxmike added on 2008-09-11 21:05:09: File Deleted - 291283: relaxmike added on 2008-08-29 20:47:27: File Added - 291284: cursor.tcl Logged In: YES user_id=1573661 Originator: YES File Added: cursor.tcl relaxmike added on 2008-08-29 20:46:09: File Added - 291283: hrbytesize.test | |||
Home Documentation Tickets | Timeline Branches Tags Wiki Login