having a problem with "selection handle" in tk-8.4

From: Random luser (w9batcve_at_explicate.org)
Date: 10/11/04

  • Next message: Arjen Markus: "Re: Convert a canvas contents into an image?"
    Date: 10 Oct 2004 21:12:23 -0700
    
    

    I have an application which works fine under tk-8.3, but is
    not behaving properly under tk-8.4. I tried to find some
    announcement or discussion that would explain that something
    was intentionally changed, but came up empty (though I may
    just have been using bad search terms).

    What the full-fledged application does is take a set of
    key-value pairs, presents the keys in a listbox, and when
    the user clicks on an item in the list the application
    overrides the default selection to return the associated
    value. A sample use is a phonebook, where the displayed
    list is the set of contact names, and the selection gets
    set to the phone numbers, which can then be pasted into
    a text box in a GUI application which is too dumb to
    extend to handle this itself.

    Under tk-8.3.4 (and earlier versions, I don't remember how
    far back this code was written) my application works fine,
    but when I upgraded to tk-8.4.6 the application broke:
    I can't get tk to let me override the selection. I've
    tried several variations on the relevant code, but I always
    wind up with either the selection being the listbox default
    (i.e., the text displayed in the listbox), or nothing at all.

    What am I doing wrong/missing/whatever?

    Here is a simplified version of the app which is enough to
    demonstrate the basic approach I'm using:
      #!/usr/bin/wish -f

      set phone(0) "222-3344"
      proc getPhone {offset maxBytes} {
              global phone
              set last [expr $offset + $maxBytes - 1]
              string range $phone([.phones.listbox curselection]) $offset $last
      }

      frame .phones
      button .phones.bye -text Quit -command exit
      listbox .phones.listbox
      .phones.listbox insert end "Joe Smith"

      pack .phones.listbox
      pack .phones.bye
      pack .phones
      focus .phones
      selection handle .phones.listbox getPhone

    Behavior under tk-8.3 (desired):
      click on "Joe Smith"; paste value into another application, see "222-3344"
    Behavior under tk-8.4 ("bug"):
      click on "Joe Smith"; paste value into another application, see "Joe Smith"

    Thanks in advance for any clues...


  • Next message: Arjen Markus: "Re: Convert a canvas contents into an image?"