• Overwrite mode?

    From Helmut Giese@21:1/5 to All on Wed Oct 18 17:07:31 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From greg@21:1/5 to Helmut Giese on Wed Oct 18 09:42:56 2023
    Helmut Giese schrieb am Mittwoch, 18. Oktober 2023 um 17:07:37 UTC+2:
    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

    Hi,
    from wiki:

    https://wiki.tcl-lang.org/page/Overwriting+an+entry+char+by+char

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to Helmut Giese on Wed Oct 18 21:10:26 2023
    On 10/18/2023 8:07 AM, Helmut Giese wrote:
    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
    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:

    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
    }

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From et99@21:1/5 to All on Wed Oct 18 21:18:00 2023
    On 10/18/2023 9:10 PM, et99 wrote:
    On 10/18/2023 8:07 AM, Helmut Giese wrote:
    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
    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:

    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
    }


    That puts was my debugging test, ignore.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Thu Oct 19 20:31:37 2023
    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,
    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
    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:

    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
    }


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Thu Oct 19 21:01:13 2023
    Am 19.10.2023 um 20:57 schrieb Harald Oehlmann:
    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,
    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
    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: >>>
    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

    About your overwrite-approach - you may also use a "-verifycmd, to
    always directly cut left, if more characters are typed.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Harald Oehlmann@21:1/5 to All on Thu Oct 19 20:57:20 2023
    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,
    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
    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:

    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Helmut Giese@21:1/5 to All on Thu Oct 19 22:14:26 2023
    Hello Harald,
    hey, that's a cool idea. Yeah, I think I will do this - and leave the
    'turn red for a moment' thing in, too.
    Thank you for this cute idea.
    Helmut

    What I do is to select the contents, so, it is replaced on next key press

    $wi select 0 end

    Take care,
    Harald

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)