diff options
author | petasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e> | 2012-04-03 18:30:36 (GMT) |
---|---|---|
committer | petasis <petasis@f3661a36-4baa-549a-d6c7-40e0ffef350e> | 2012-04-03 18:30:36 (GMT) |
commit | c80cc22cb3faa2fee315afce3ab3546499d30941 (patch) | |
tree | 49b664cda3f0606c0709282515e8b228c1d43d35 | |
parent | 604ceba08aaf9cbb726fa370e49df7a74b96cc13 (diff) | |
download | tkdnd-c80cc22cb3faa2fee315afce3ab3546499d30941.zip tkdnd-c80cc22cb3faa2fee315afce3ab3546499d30941.tar.gz tkdnd-c80cc22cb3faa2fee315afce3ab3546499d30941.tar.bz2 |
TkDND 2.3 released.
Added drag support for mouse buttons 2 & 3 under windows.
-rw-r--r-- | Changelog | 8 | ||||
-rw-r--r-- | library/tkdnd.tcl | 28 | ||||
-rw-r--r-- | win/OleDND.h | 31 | ||||
-rw-r--r-- | win/TkDND_OleDND.cpp | 20 |
4 files changed, 64 insertions, 23 deletions
@@ -1,3 +1,11 @@ +2012-03-03 Petasis George <petasis@iit.demokritos.gr> + TkDND 2.3 released. + * library/tkdnd_windows.tcl: + * win/OleDND.h: + * win/TkDND_OleDND.cpp: Fix in TkDND_DropSource::QueryContinueDrag, + to support dragging with all mouse buttons. Bug reported by + Michael Fersch. + 2011-09-24 Petasis George <petasis@iit.demokritos.gr> * win/OleDND.h: Added definition of WINVER to version 5, when compiling with MinGW, which defines it with version 4. SF Bug ID: 3411338. diff --git a/library/tkdnd.tcl b/library/tkdnd.tcl index b97385d..f09e133 100644 --- a/library/tkdnd.tcl +++ b/library/tkdnd.tcl @@ -50,12 +50,12 @@ namespace eval tkdnd { variable _windowingsystem - bind TkDND_Drag1 <ButtonPress-1> {tkdnd::_begin_drag press %W %s %X %Y} - bind TkDND_Drag1 <B1-Motion> {tkdnd::_begin_drag motion %W %s %X %Y} - bind TkDND_Drag2 <ButtonPress-2> {tkdnd::_begin_drag press %W %s %X %Y} - bind TkDND_Drag2 <B2-Motion> {tkdnd::_begin_drag motion %W %s %X %Y} - bind TkDND_Drag3 <ButtonPress-3> {tkdnd::_begin_drag press %W %s %X %Y} - bind TkDND_Drag3 <B3-Motion> {tkdnd::_begin_drag motion %W %s %X %Y} + bind TkDND_Drag1 <ButtonPress-1> {tkdnd::_begin_drag press 1 %W %s %X %Y} + bind TkDND_Drag1 <B1-Motion> {tkdnd::_begin_drag motion 1 %W %s %X %Y} + bind TkDND_Drag2 <ButtonPress-2> {tkdnd::_begin_drag press 2 %W %s %X %Y} + bind TkDND_Drag2 <B2-Motion> {tkdnd::_begin_drag motion 2 %W %s %X %Y} + bind TkDND_Drag3 <ButtonPress-3> {tkdnd::_begin_drag press 3 %W %s %X %Y} + bind TkDND_Drag3 <B3-Motion> {tkdnd::_begin_drag motion 3 %W %s %X %Y} # ---------------------------------------------------------------------------- # Command tkdnd::initialise: Initialise the TkDND package. @@ -254,7 +254,7 @@ proc tkdnd::drop_target { mode path { types {} } } { # ---------------------------------------------------------------------------- # Command tkdnd::_begin_drag # ---------------------------------------------------------------------------- -proc tkdnd::_begin_drag { event source state X Y } { +proc tkdnd::_begin_drag { event button source state X Y } { variable _x0 variable _y0 variable _state @@ -274,7 +274,7 @@ proc tkdnd::_begin_drag { event source state X Y } { if { [string equal $_state "press"] } { if { abs($_x0-$X) > 3 || abs($_y0-$Y) > 3 } { set _state "done" - _init_drag $source $state $X $Y + _init_drag $button $source $state $X $Y } } } @@ -284,7 +284,7 @@ proc tkdnd::_begin_drag { event source state X Y } { # ---------------------------------------------------------------------------- # Command tkdnd::_init_drag # ---------------------------------------------------------------------------- -proc tkdnd::_init_drag { source state rootX rootY } { +proc tkdnd::_init_drag { button source state rootX rootY } { # Call the <<DragInitCmd>> binding. set cmd [bind $source <<DragInitCmd>>] if {[string length $cmd]} { @@ -303,7 +303,7 @@ proc tkdnd::_init_drag { source state rootX rootY } { } win32 - windows { - set action [_DoDragDrop $source $actions $types $data] + set action [_DoDragDrop $source $actions $types $data $button] } aqua { set action [macdnd::dodragdrop $source $actions $types $data] @@ -314,7 +314,7 @@ proc tkdnd::_init_drag { source state rootX rootY } { } ## Call _end_drag to notify the widget of the result of the drag ## operation... - _end_drag $source {} $action {} $data {} $state $rootX $rootY + _end_drag $button $source {} $action {} $data {} $state $rootX $rootY } } };# tkdnd::_init_drag @@ -322,7 +322,7 @@ proc tkdnd::_init_drag { source state rootX rootY } { # ---------------------------------------------------------------------------- # Command tkdnd::_end_drag # ---------------------------------------------------------------------------- -proc tkdnd::_end_drag { source target action type data result +proc tkdnd::_end_drag { button source target action type data result state rootX rootY } { set rootX 0 set rootY 0 @@ -342,7 +342,7 @@ proc tkdnd::_end_drag { source target action type data result } win32 - windows { - set action [_DoDragDrop $source $actions $types $data] + set action [_DoDragDrop $source $actions $types $data $button] } aqua { macdnd::dodragdrop $source $actions $types $data @@ -353,7 +353,7 @@ proc tkdnd::_end_drag { source target action type data result } ## Call _end_drag to notify the widget of the result of the drag ## operation... - _end_drag $source {} $action {} $data {} $state $rootX $rootY + _end_drag $button $source {} $action {} $data {} $state $rootX $rootY } } };# tkdnd::_end_drag diff --git a/win/OleDND.h b/win/OleDND.h index bf896ee..6f81150 100644 --- a/win/OleDND.h +++ b/win/OleDND.h @@ -1,8 +1,8 @@ /* * OleDND.h -- * - * This file implements the windows portion of the drag&drop mechanish - * for the tk toolkit. The protocol in use under windows is the + * This file implements the windows portion of the drag&drop mechanism + * for the Tk toolkit. The protocol in use under windows is the * OLE protocol. Based on code wrote by Gordon Chafee. * * This software is copyrighted by: @@ -1176,6 +1176,8 @@ private: ****************************************************************************/ class TkDND_DropSource : public IDropSource { public: + int button; + // IUnknown members HRESULT __stdcall QueryInterface(REFIID iid, void ** ppvObject) { // check to see what interface has been requested @@ -1209,8 +1211,23 @@ public: // cancel the drop if(fEscapePressed == TRUE) return DRAGDROP_S_CANCEL; - // if the <LeftMouse> button has been released, then do the drop! - if((grfKeyState & MK_LBUTTON) == 0) return DRAGDROP_S_DROP; + switch (button) { + case 1: { + // if the <LeftMouse> button has been released, then do the drop! + if((grfKeyState & MK_LBUTTON) == 0) return DRAGDROP_S_DROP; + break; + } + case 2: { + // if the <MiddleMouse> button has been released, then do the drop! + if((grfKeyState & MK_MBUTTON) == 0) return DRAGDROP_S_DROP; + break; + } + case 3: { + // if the <RightMouse> button has been released, then do the drop! + if((grfKeyState & MK_RBUTTON) == 0) return DRAGDROP_S_DROP; + break; + } + } // continue with the drag-drop return S_OK; @@ -1225,6 +1242,12 @@ public: // Constructor / Destructor TkDND_DropSource() { m_lRefCount = 1; + button = 1; + }; /* TkDND_DropSource */ + + TkDND_DropSource(int b) { + m_lRefCount = 1; + button = b; }; /* TkDND_DropSource */ ~TkDND_DropSource() {}; diff --git a/win/TkDND_OleDND.cpp b/win/TkDND_OleDND.cpp index 1456681..ebec0d2 100644 --- a/win/TkDND_OleDND.cpp +++ b/win/TkDND_OleDND.cpp @@ -2,7 +2,7 @@ * TkDND_OleDND.h -- Tk OleDND Drag'n'Drop Protocol Implementation
*
* This file implements the unix portion of the drag&drop mechanism
- * for the tk toolkit. The protocol in use under windows is the
+ * for the Tk toolkit. The protocol in use under windows is the
* OleDND protocol.
*
* This software is copyrighted by:
@@ -123,7 +123,7 @@ int TkDND_DoDragDropObjCmd(ClientData clientData, Tcl_Interp *interp, DWORD actions = 0;
DWORD dwEffect;
DWORD dwResult;
- int status, elem_nu, i, index, nDataLength;
+ int status, elem_nu, i, index, nDataLength, button = 1;
char *ptr;
Tcl_UniChar *unicode, *ptr_u;
FORMATETC *m_pfmtetc;
@@ -145,12 +145,22 @@ int TkDND_DoDragDropObjCmd(ClientData clientData, Tcl_Interp *interp, refuse_drop, ActionDefault
};
- if (objc != 5) {
- Tcl_WrongNumArgs(interp, 1, objv, "path actions types data");
+ if (objc != 5 && objc != 6) {
+ Tcl_WrongNumArgs(interp, 1, objv, "path actions types data ?mouse-button?");
return TCL_ERROR;
}
Tcl_ResetResult(interp);
+ /* Get the mouse button. It must be one of 1, 2, or 3. */
+ if (objc > 5) {
+ status = Tcl_GetIntFromObj(interp, objv[5], &button);
+ if (status != TCL_OK) return status;
+ if (button < 1 || button > 3) {
+ Tcl_SetResult(interp, "button must be either 1, 2, or 3", TCL_STATIC);
+ return TCL_ERROR;
+ }
+ }
+
/* Process drag actions. */
status = Tcl_ListObjGetElements(interp, objv[2], &elem_nu, &elem);
if (status != TCL_OK) return status;
@@ -302,7 +312,7 @@ int TkDND_DoDragDropObjCmd(ClientData clientData, Tcl_Interp *interp, return TCL_ERROR;
}
- pDropSource = new TkDND_DropSource();
+ pDropSource = new TkDND_DropSource(button);
if (pDropSource == NULL) {
pDataObject->Release();
Tcl_SetResult(interp, "unable to create OLE Drop Source object",TCL_STATIC);
|