Hello out there,
is it possible to set an entry to 'overwrite' mode instead of 'insert'
mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
Hello out there,In the FWIW dept. if you like quick hacks, and/or you want to modify all entry widgets, the following is the code (with a mod) that handles inserting characters and is bound to <Key> in the Entry class:
is it possible to set an entry to 'overwrite' mode instead of 'insert'
mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
On 10/18/2023 8:07 AM, Helmut Giese wrote:
Hello out there,In the FWIW dept. if you like quick hacks, and/or you want to modify all entry widgets, the following is the code (with a mod) that handles inserting characters and is bound to <Key> in the Entry class:
is it possible to set an entry to 'overwrite' mode instead of 'insert'
mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
proc ::tk::EntryInsert {w s} {
puts "insert into $w /$s/"
if {$s eq ""} {
return
}
catch {
set insert [$w index insert]
if {([$w index sel.first] <= $insert)
&& ([$w index sel.last] >= $insert)} {
$w delete sel.first sel.last
}
}
$w insert insert $s
$w delete insert ;# makes this write over mode
EntrySeeInsert $w
}
By adding the above
$w delete insert
you can make all entry widgets be overwrite mode. Maybe there should be a config parameter in entry and then make that conditional per widget by perhaps,
if [$w cget -writeover] {
$w delete insert
}
On 10/18/2023 8:07 AM, Helmut Giese wrote:
Hello out there,In the FWIW dept. if you like quick hacks, and/or you want to modify all entry widgets, the following is the code (with a mod) that handles inserting characters and is bound to <Key> in the Entry class:
is it possible to set an entry to 'overwrite' mode instead of 'insert'
mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
proc ::tk::EntryInsert {w s} {
puts "insert into $w /$s/"
if {$s eq ""} {
return
}
catch {
set insert [$w index insert]
if {([$w index sel.first] <= $insert)
&& ([$w index sel.last] >= $insert)} {
$w delete sel.first sel.last
}
}
$w insert insert $s
$w delete insert ;# makes this write over mode
EntrySeeInsert $w
}
By adding the above
$w delete insert
you can make all entry widgets be overwrite mode. Maybe there should be a config parameter in entry and then make that conditional per widget by perhaps,
if [$w cget -writeover] {
$w delete insert
}
Am 19.10.2023 um 20:31 schrieb Helmut Giese:
Hello et99,
an interesting approach, but I didn't plan to change the behaviour of
all widgets. Meanwhile I found a solution for my problem which was:
- I have a very small entry ( just 2 chars wide)
- When the user starts entering a new value the former content gets
shifted out - which the user might not realize.
- When the editing is over the new content is truncated to the last 2
digits - which the user might still not realize.
My solution was
- to enlarge the width of the entry a bit so that the former content
is still visible and
- on finishing the (new) value is for a moment turned red which should
alert all but the most ignorant user.
Thanks for giving my problem a thought, I appreciate
Helmut
On 10/18/2023 8:07 AM, Helmut Giese wrote:
Hello out there,In the FWIW dept. if you like quick hacks, and/or you want to modify
is it possible to set an entry to 'overwrite' mode instead of 'insert' >>>> mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
all entry widgets, the following is the code (with a mod) that
handles inserting characters and is bound to <Key> in the Entry class: >>>
proc ::tk::EntryInsert {w s} {
puts "insert into $w /$s/"
if {$s eq ""} {
return
}
catch {
set insert [$w index insert]
if {([$w index sel.first] <= $insert)
&& ([$w index sel.last] >= $insert)} {
$w delete sel.first sel.last
}
}
$w insert insert $s
$w delete insert ;# makes this write over mode
EntrySeeInsert $w
}
By adding the above
$w delete insert
you can make all entry widgets be overwrite mode. Maybe there should
be a config parameter in entry and then make that conditional per
widget by perhaps,
if [$w cget -writeover] {
$w delete insert
}
What I do is to select the contents, so, it is replaced on next key press
$wi select 0 end
Take care,
Harald
Hello et99,
an interesting approach, but I didn't plan to change the behaviour of
all widgets. Meanwhile I found a solution for my problem which was:
- I have a very small entry ( just 2 chars wide)
- When the user starts entering a new value the former content gets
shifted out - which the user might not realize.
- When the editing is over the new content is truncated to the last 2
digits - which the user might still not realize.
My solution was
- to enlarge the width of the entry a bit so that the former content
is still visible and
- on finishing the (new) value is for a moment turned red which should
alert all but the most ignorant user.
Thanks for giving my problem a thought, I appreciate
Helmut
On 10/18/2023 8:07 AM, Helmut Giese wrote:
Hello out there,In the FWIW dept. if you like quick hacks, and/or you want to modify all entry widgets, the following is the code (with a mod) that handles inserting characters and is bound to <Key> in the Entry class:
is it possible to set an entry to 'overwrite' mode instead of 'insert'
mode? I haven't found anything in the docs.
Any help will be greatly appreciated
Helmut
proc ::tk::EntryInsert {w s} {
puts "insert into $w /$s/"
if {$s eq ""} {
return
}
catch {
set insert [$w index insert]
if {([$w index sel.first] <= $insert)
&& ([$w index sel.last] >= $insert)} {
$w delete sel.first sel.last
}
}
$w insert insert $s
$w delete insert ;# makes this write over mode
EntrySeeInsert $w
}
By adding the above
$w delete insert
you can make all entry widgets be overwrite mode. Maybe there should be a config parameter in entry and then make that conditional per widget by perhaps,
if [$w cget -writeover] {
$w delete insert
}
What I do is to select the contents, so, it is replaced on next key press
$wi select 0 end
Take care,
Harald
Sysop: | Keyop |
---|---|
Location: | Huddersfield, West Yorkshire, UK |
Users: | 463 |
Nodes: | 16 (2 / 14) |
Uptime: | 157:16:22 |
Calls: | 9,384 |
Calls today: | 4 |
Files: | 13,561 |
Messages: | 6,096,000 |