Skip to content

Commit

Permalink
Pull request #36 merged.
Browse files Browse the repository at this point in the history
  • Loading branch information
petasis committed Jul 15, 2019
1 parent 36c5654 commit 33c3323
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 27 deletions.
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
2019-07-15 Petasis George <[email protected]>
* library/tkdnd.tcl: Allowed ::tkdnd::drag_source to accept multiple
mouse buttons, as the event that initiates a drag action.

* library/tkdnd.tcl: Merged pull request #36.
(https://github.com/petasis/tkdnd/pull/36).

* unix/TkDND_XDND.c: Changed how TkDND_GetToplevelFromWrapper()
selects the topelvel. Patch from Florian Pigorsch.
(https://github.com/petasis/tkdnd/issues/34)
Expand Down
15 changes: 8 additions & 7 deletions doc/tkDND.htm
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ <H2>SYNOPSIS</H2>
<B>tkdnd::drop_target unregister</B><I> window</I>
<P>

<B>tkdnd::drag_source register</B><I> window ?type-list? ?mouse-button?</I>
<B>tkdnd::drag_source register</B><I> window ?type-list? ?mouse-buttons?</I>
<BR>

<B>tkdnd::drag_source unregister</B><I> window</I>
Expand Down Expand Up @@ -88,7 +88,7 @@ <H2>INTRODUCTION</H2>
Thus, <I>window</I> will stop receiving events related to drop operations.
It is an error to use this command for a <I>window</I> that has not been
registered as a drop target with <B>tkdnd::drop_target register</B>.
<DT><B>tkdnd::drag_source register</B><I> window ?type-list? ?mouse-button?</I><DD>
<DT><B>tkdnd::drag_source register</B><I> window ?type-list? ?mouse-buttons?</I><DD>
This command will register <I>window</I> as a drag source. A drag source is a
widget than can start a drag action. <I>window</I> must exist when this command
is executed and this command can be executed multiple times on a widget.
Expand All @@ -103,10 +103,11 @@ <H2>INTRODUCTION</H2>
even a different type list. If <I>type-list</I> is not specified, it defaults to
the empty list.
<P>
Finally, <I>mouse-button</I> is the mouse button that will be used for starting
the drag action. It can have any of the values 1 (left mouse button),
2 (middle mouse button - wheel) and 3 (right mouse button).
If <I>mouse-button</I> is not specified, it defaults to 1.
Finally, <I>mouse-buttons</I> is one or more mouse buttons that will be used for
starting the drag action. It can have any of the values &quot;1&quot; (left mouse
button), &quot;2&quot; (middle mouse button - wheel) and &quot;3&quot; (right mouse button). If
<I>mouse-buttons</I> is not specified, it defaults to &quot;1&quot; (left mouse button).
Multiple mouse buttons can be specified as a list of values (i.e. {1 3}).
<DT><B>tkdnd::drag_source unregister</B><I> window</I><DD>
This command will stop <I>window</I> from being a drag source.
Thus, <I>window</I> will stop receiving events related to drag operations.
Expand Down Expand Up @@ -527,6 +528,6 @@ <H2>KEYWORDS</H2>
This document was created by
<A HREF="/man/man2html">man2html</A>,
using the manual pages.<BR>
Time: 22:24:05 GMT, July 13, 2019
Time: 10:56:09 GMT, July 15, 2019
</BODY>
</HTML>
13 changes: 7 additions & 6 deletions doc/tkDND.n
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ TkDND \- Tk Drag and Drop Interface
.br
\fBtkdnd::drop_target unregister\fI window\fR
.PP
\fBtkdnd::drag_source register\fI window ?type-list? ?mouse-button?\fR
\fBtkdnd::drag_source register\fI window ?type-list? ?mouse-buttons?\fR
.br
\fBtkdnd::drag_source unregister\fI window\fR
.PP
Expand Down Expand Up @@ -327,7 +327,7 @@ Thus, \fIwindow\fR will stop receiving events related to drop operations.
It is an error to use this command for a \fIwindow\fR that has not been
registered as a drop target with \fBtkdnd::drop_target register\fR.
.TP
\fBtkdnd::drag_source register\fI window ?type-list? ?mouse-button?\fR
\fBtkdnd::drag_source register\fI window ?type-list? ?mouse-buttons?\fR
This command will register \fIwindow\fR as a drag source. A drag source is a
widget than can start a drag action. \fIwindow\fR must exist when this command
is executed and this command can be executed multiple times on a widget.
Expand All @@ -342,10 +342,11 @@ list is indicative/informative. \fIwindow\fR can initiate a drag action with
even a different type list. If \fItype-list\fR is not specified, it defaults to
the empty list.

Finally, \fImouse-button\fR is the mouse button that will be used for starting
the drag action. It can have any of the values 1 (left mouse button),
2 (middle mouse button - wheel) and 3 (right mouse button).
If \fImouse-button\fR is not specified, it defaults to 1.
Finally, \fImouse-buttons\fR is one or more mouse buttons that will be used for
starting the drag action. It can have any of the values "1" (left mouse
button), "2" (middle mouse button - wheel) and "3" (right mouse button). If
\fImouse-buttons\fR is not specified, it defaults to "1" (left mouse button).
Multiple mouse buttons can be specified as a list of values (i.e. {1 3}).
.TP
\fBtkdnd::drag_source unregister\fI window\fR
This command will stop \fIwindow\fR from being a drag source.
Expand Down
30 changes: 16 additions & 14 deletions library/tkdnd.tcl
Original file line number Diff line number Diff line change
Expand Up @@ -178,21 +178,23 @@ namespace eval ::tkdnd {
# ----------------------------------------------------------------------------
proc ::tkdnd::drag_source { mode path { types {} } { event 1 }
{ tagprefix TkDND_Drag } } {
set tags [bindtags $path]
set idx [lsearch $tags ${tagprefix}$event]
switch -- $mode {
register {
if { $idx != -1 } {
## No need to do anything!
# bindtags $path [lreplace $tags $idx $idx ${tagprefix}$event]
} else {
bindtags $path [linsert $tags 1 ${tagprefix}$event]
foreach single_event $event {
set tags [bindtags $path]
set idx [lsearch $tags ${tagprefix}$single_event]
switch -- $mode {
register {
if { $idx != -1 } {
## No need to do anything!
# bindtags $path [lreplace $tags $idx $idx ${tagprefix}$single_event]
} else {
bindtags $path [linsert $tags 1 ${tagprefix}$single_event]
}
_drag_source_update_types $path $types
}
_drag_source_update_types $path $types
}
unregister {
if { $idx != -1 } {
bindtags $path [lreplace $tags $idx $idx]
unregister {
if { $idx != -1 } {
bindtags $path [lreplace $tags $idx $idx]
}
}
}
}
Expand Down

0 comments on commit 33c3323

Please sign in to comment.