This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Tkdnd mouse cursor handling patch
Type: enhancement Stage: patch review
Components: Tkinter Versions: Python 3.10, Python 3.9
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: loewis Nosy List: flupke, gpolo, klappnase, loewis
Priority: low Keywords: patch

Created on 2006-07-20 10:28 by klappnase, last changed 2022-04-11 14:56 by admin.

Files
File name Uploaded Description Edit
patch_Tkdnd.diff klappnase, 2006-07-20 10:28 against 18168
Tkdnd.diff klappnase, 2009-04-23 16:45 against 66717
Messages (3)
msg50723 - (view) Author: klappnase (klappnase) * Date: 2006-07-20 10:28
This patch improves two things I always found annoying
with Tkdnd.
First, it is not possible to change the default cursor
("hand2") that is used for drag and drop operations,
second, this cursor always shows up on <ButtonPress>
events and not on <Motion> events, as I think it should.
This has the ugly effect that if for example you use
Tkdnd to drag items from a Listbox, each time the user
selects a new item from the Listbox, the "hand2" cursor
pops up.

To fix the first issue I added a "dndcursor" option to
the dnd_start() function, which defaults to "hand2" to
keep the "classic" behavior intact.
Second I added a self.dndcursor attribute to the
DnDHandler class that stores this dndcursor's value;
then I moved the call that actually changes the
widget's cursor into the DnDHandler.on_motion() method
to make sure that this cursor only shows when actually
some drag occurs. self.dndcursor is set to None then,
to avoid multiple calls to "widget['cursor'] == ...". I
know that this is a slight change to the original
behavior, however I doubt that anyone will miss it.

Regards

Michael
msg86347 - (view) Author: Guilherme Polo (gpolo) * (Python committer) Date: 2009-04-23 00:45
I just created a sample listbox with drag & drop support and it indeed
looks better if the "hand2" cursor or whatever cursor is set only shows
up when motion starts. But, for the sample included with Tkdnd, I find
it better to show up the different cursor when clicking the canvas item
instead of waiting to starting move it.
Are you willing to adjust that ?

The first feature added -- to support custom cursor is fine, just this
second change needs to be rethought.
msg86369 - (view) Author: klappnase (klappnase) * Date: 2009-04-23 16:45
Maybe this depends on whether the dragged item is "clickable" like
listbox items and buttons or not , like the Labels in the Tkdnd demo.
Ok, I wrote a second patch that solves this by adding another option to
dnd_start(); if this option is set to True (the default) the user gets
the classic behavior, if set to False the cursor changes when the motion
starts, as in the initial patch. I couldn't figure out a good name for
this option, so I called it "swapcursoronclick", at least the name says
what it is for ^_^
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43699
2020-11-18 19:52:20iritkatrielsetversions: + Python 3.9, Python 3.10, - Python 3.2
2014-09-09 08:55:16flupkesetnosy: + flupke
2010-08-24 19:29:21BreamoreBoysetstage: test needed -> patch review
versions: + Python 3.2, - Python 3.1, Python 2.7
2009-04-23 16:45:59klappnasesetfiles: + Tkdnd.diff

messages: + msg86369
2009-04-23 00:45:46gpolosetversions: + Python 3.1, Python 2.7, - Python 2.6, Python 3.0
nosy: + gpolo

messages: + msg86347

type: behavior -> enhancement
2009-03-30 04:49:09ajaksu2setpriority: normal -> low
stage: test needed
type: behavior
versions: + Python 2.6, Python 3.0
2006-07-20 10:28:26klappnasecreate