in reply to How to make a Tk::Button move/slide within a Tk::Table

In motion(), you're calling slideButton() when $isDragging is TRUE. What you want to do is call that function when you've stopped dragging the button. I haven't looked too closely at your code but suspect moving the call to slideButton() from motion() to buttonRelease() might fix the problem (which possibly means you'll no longer need $isDragging or buttonPress() and its associated bind()).

-- Ken

Replies are listed 'Best First'.
Re^2: How to make a Tk::Button move/slide within a Tk::Table
by bcarroll (Pilgrim) on Feb 08, 2012 at 20:53 UTC
    The idea is to have the button move while dragging and stay in that location when the button is released.

      My mental visualisation of what you're trying to achieve was clearly wrong. My apologies.

      You'll need to keep track of each cell the button is dragged through. When it enters a new cell, you'll need to blank out the last cell: probably easiest to use a Label without text, e.g. $table->put($r, $c, '').

      You also mentioned you wanted to move any existing button to a new cell ("... push the button under it to the right or to the next row ..."). I think you'll need to capture the return value of $table->put() to achieve this; although there's probably other ways of doing it.

      I hope that's a bit closer to what you're after.

      -- Ken

        I realized that I wasn't updating the row and col of $buttons$selectedButton in slideButton(). I added
        $buttons[$selectedButton]{'row'} = $mRow; $buttons[$selectedButton]{'col'} = $mCol;

        to slideButton() subroutine and now the blinking/left over widgets are gone...