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?"

    Relevant Pages

    • Re: Select range & copy
      ... I changed the range name of the ListBox stuff to mRefList ... "tvac" wrote: ... > Private Sub ListBox1_Click ... >> The first 2 columns have common data regardless of the selection. ...
      (microsoft.public.excel.programming)
    • Re: List of values
      ... I have to assume that the listbox is set to ... single-selection listbox. ... Private Sub ButtonOK_Click ... have shown is only the code to load the data into the listbox and display ...
      (microsoft.public.word.vba.general)
    • Re: Creating a Drop down list where can pick more than one choice
      ... do both tasks (make the listbox visible, and write the selected items into ... <MS ACCESS MVP> ... "Ken Snell MVP" wrote: ... Or do you want each selection to appear in the ...
      (microsoft.public.access.forms)
    • Re: Last Selection from MultiSelect Listbox
      ... What you can do is track the listbox selection in an array by modifying an array every time the listbox is changed. ... Dim idx As Integer, i As Integer ...
      (microsoft.public.excel.programming)
    • Re: List boxes in Microfocus Dialog System/Net Express?
      ... listbox is question is called a "Selection Box" in Dialog System and ... Dialog System's listbox rows start at 1. ... It wont necessarily be apparent from the demo project titles ... None of the examples I've found show how to accomplish what I'm trying ...
      (comp.lang.cobol)