• Error in capturing selection

    From Luc@21:1/5 to All on Thu Feb 2 03:43:50 2023
    $::bottomtextbox insert end "\n[$::HASFOCUS tag ranges sel]"

    Type abcdef

    Highlight. It prints:

    1.0 1.6

    So it doesn't give me the text. It gives me the indices of the
    selection. OK then:

    $::bottomtextbox insert end "\n[$::HASFOCUS get [$::HASFOCUS tag ranges sel]]"

    Can't even type. It throws an error:

    bad text index ""
    while executing
    "$::HASFOCUS get [$::HASFOCUS tag ranges sel]"


    What am I doing wrong this time?

    --
    Luc


    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Martyn Smith@21:1/5 to All on Thu Feb 2 01:01:17 2023
    Le jeudi 2 février 2023 à 07:43:55 UTC+1, Luc a écrit :
    $::bottomtextbox insert end "\n[$::HASFOCUS tag ranges sel]"

    Type abcdef

    Highlight. It prints:

    1.0 1.6

    So it doesn't give me the text. It gives me the indices of the
    selection. OK then:

    $::bottomtextbox insert end "\n[$::HASFOCUS get [$::HASFOCUS tag ranges sel]]"

    Can't even type. It throws an error:

    bad text index ""
    while executing
    "$::HASFOCUS get [$::HASFOCUS tag ranges sel]"


    What am I doing wrong this time?

    --
    Luc

    The get requires 2 arguments and the 'tag ranges sel' returns a list of 2 items so you need the {*} operator to expand the list into 2 arguments
    [$::HASFOCUS get {*}[$::HASFOCUS tag ranges sel]]

    Martyn

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