| Ticket UUID: | 1009543 | |||
| Title: | Better handling of up/down in text widgets | |||
| Type: | Patch | Version: | None | |
| Submitter: | lio_lion | Created on: | 2004-08-15 13:48:53 | |
| Subsystem: | None | Assigned To: | nobody | |
| Priority: | 5 Medium | Severity: | ||
| Status: | Closed | Last Modified: | 2004-08-18 23:04:14 | |
| Resolution: | Rejected | Closed By: | andreas_kupries | |
| Closed on: | 2004-08-18 16:04:14 | |||
| Description: |
This is in regards to the tk text windows.
I find that the up/down keys do not work as one would
expect in a text box that includes wrapped lines. It
does not go to the character immediately above, rather
goes to the character at the same index in the 'line'
above which could actually be a number of lines up.
Therefore I recommend changing the ::tk::TextUpDownLine
to something more along the lines of below.
Just a quick note it is not fully complete. I have not
added the ::tk::Priv as before (which should be added)
and there is a small bug with it when the cursor is at
the very end of the line, although I believe that bug
is due possibly to a bug in the return of [$inputbox
bbox insert] when the character is at the end of the line.
I also have it as 2 fucntions which could be
reorganised to be 1 function as the old code.
#///////////////////////////////////////////////////////////////////////////////
# UpKeyPressed (inputbox)
# Called by a window when the user uses the up key in
a text box. It returns
# the index of the character 1 line above the
insertion cursor
proc UpKeyPressed { inputbox } {
$inputbox see insert
set bbox [$inputbox bbox insert]
set xpos [expr [lindex $bbox 0]+[lindex $bbox 2]/2]
set ypos [lindex $bbox 1]
set height [lindex $bbox 3]
if { $ypos > $height } {
return [$inputbox index "@$xpos,[expr $ypos-$height]"]
} else {
$inputbox yview scroll -1 units
update
set ypos [lindex [$inputbox bbox insert] 1]
set height [lindex [$inputbox bbox insert] 3]
if { $ypos > $height } {
return [$inputbox index "@$xpos,[expr $ypos-$height]"]
}
}
return [$inputbox index insert]
}
#///////////////////////////////////////////////////////////////////////////////
#///////////////////////////////////////////////////////////////////////////////
# DownKeyPressed (inputbox)
# Called by a window when the user uses the down key
in a text box. It returns
# the index of the character 1 line below the
insertion cursor
proc DownKeyPressed { inputbox } {
$inputbox see insert
set bbox [$inputbox bbox insert]
set xpos [expr [lindex $bbox 0]+[lindex $bbox 2]/2]
set ypos [lindex $bbox 1]
set height [lindex $bbox 3]
set inputboxheight [lindex [$inputbox configure
-height] end]
if { [expr $ypos+$height] < [expr
$inputboxheight*$height] } {
return [$inputbox index "@$xpos,[expr $ypos+$height]"]
} else {
$inputbox yview scroll +1 units
update
set ypos [lindex [$inputbox bbox insert] 1]
set height [lindex [$inputbox bbox insert] 3]
set inputboxheight [lindex [$inputbox configure
-height] end]
if { [expr $ypos+$height] < [expr
$inputboxheight*$height] } {
return [$inputbox index "@$xpos,[expr $ypos+$height]"]
}
}
return [$inputbox index insert]
}
#///////////////////////////////////////////////////////////////////////////////
| |||
| User Comments: |
andreas_kupries added on 2004-08-18 23:04:14:
Logged In: YES user_id=75003 "Tk Toolkit" is the correct place. Note that the resolution rejected means just that it is not valid here in tcllib. It does not mean that the report is invalid and such. I haven't actually read more than required to know that it doesn't belong here. lio_lion added on 2004-08-18 13:17:17: Logged In: YES user_id=971615 I just found the project "Tk Toolkit" and believe this is probably supposed to go there (and posted it there). However I will leave it here as well just in case this was the correct place. If it is the wrong place dont hesitate to delete this thread. Lio. | |||
Home
Blog
Docs
Downloads
Tickets
Timeline
Branches
Tags
Wiki