DragAndDropManager.st
author Stefan Vogel <sv@exept.de>
Mon, 08 Aug 2016 17:06:34 +0200
changeset 3725 3fb5cf9108cf
parent 3623 9ddec519a3c6
child 3774 cee263839e68
permissions -rw-r--r--
#REFACTORING by stefan class: DragAndDropManager changed: #displayObjectFor:on: do not send #clarMaskePixels (it is alread done in #onDevice:)
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     1
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     2
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
     3
	      All Rights Reserved
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     4
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     5
 This software is furnished under a license and may be used
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     6
 only in accordance with the terms of that license and with the
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     8
 be provided or otherwise made available to, or used by, any
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
     9
 other person.  No title to or ownership of the software is
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    10
 hereby transferred.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    11
"
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
    12
"{ Package: 'stx:libview2' }"
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
    13
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
    14
"{ NameSpace: Smalltalk }"
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
    15
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    16
Object subclass:#DragAndDropManager
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
    17
	instanceVariableNames:'dropContext dragView dropAction dragOffset handler restoreBlock
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
    18
		alienCursor enabledCursor disabledCursor canDrop escapePressed
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
    19
		passiveAction autoScrollTask disabledFlag giveFocusToTargetWidget
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
    20
		notifyEndOfDropAction savedCursor'
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
    21
	classVariableNames:'DragContextQuerySignal DragOriginatorQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
    22
		DragOffsetQuerySignal ActiveDragAndDropManagers'
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
    23
	poolDictionaries:''
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
    24
	category:'Interface-DragAndDrop'
342
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
    25
!
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
    26
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    28
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    29
copyright
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    30
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    31
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    32
	      All Rights Reserved
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    33
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    34
 This software is furnished under a license and may be used
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    35
 only in accordance with the terms of that license and with the
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    36
 inclusion of the above copyright notice.   This software may not
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    37
 be provided or otherwise made available to, or used by, any
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    38
 other person.  No title to or ownership of the software is
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    39
 hereby transferred.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    40
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    41
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    42
!
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    43
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    44
documentation
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    45
"
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    46
    this class provides low-level drag & drop mechanisms.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    47
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    48
    Easy to use interface interfaces:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    49
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    50
    A drag is usually initiated by a view or its application model,
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    51
    when a selection is moved (for example, SelectionInListView can
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    52
    be initializd to do so). 
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    53
    There, the view creates a collection of dropObjects from its selection,
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    54
    and starts the drag operation with:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    55
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    56
	DragAndDropManager startDrag:collectionOfDragObjects from:aView.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    57
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    58
    This easy to use interface starts a drag and also drops the collection
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    59
    into the target view.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    60
    While dragging, a thumbsUp cursor is shown, if the view-under-the-drag
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    61
    can handle a drop, a thumbsDown is shown if not, and a question mark
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    62
    is shown for alien views (which means: we dont know).
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    63
    Alien view drop is supported (but no 'canDrop' query).
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    64
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    65
    For rubber-band line dragging, two more easy-to-use startup methods are
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    66
    provided:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    67
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    68
	DragAndDropManager
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    69
		startLineDragIn:aView at:position
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    70
		atEnd:aFourArgEndBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    71
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    72
    and:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    73
	DragAndDropManager
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    74
		startArrowDragIn:aView at:position
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    75
		atEnd:aFourArgEndBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    76
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    77
    both of the above expect a 4-arg block to be passed, which will be
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    78
    evaluated at end-drag, with the target view, its viewID, the drop position
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    79
    on the screen and within the target view as arguments.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    80
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    81
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    82
    Expert interface:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    83
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    84
    More control over the dragging (i.e. the drawing procedure)
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    85
    can be optained, by passing a dragBlock and an endDrag action:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    86
        
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    87
	aDragAndDropMgr := DragAndDropManager new.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    88
	aDragAndDropMgr dropObjects:(self collectionOfDragObjects).
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    89
	aDragAndDropMgr 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    90
	    startOpaqueDrag:[:aPoint :aView :dropObjects | 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    91
				self 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    92
				    showDragging:dropObjects
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    93
				    in:aView 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    94
				    at:aPoint - (xOffset@0)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    95
			    ]
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    96
	    offset:clickOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    97
	    extent:saveUnderExtent
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    98
	    in:self
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    99
	    at:clickPoint
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   100
	    atEnd:[:v :vId :posScreen :posView | ... ]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   101
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   102
    the arguments are:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   103
      startOpaqueDrag:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   104
	a 3-arg block, which is evaluated by the d&d manager whenever the
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   105
	mouse moves; it is supposed to draw the dropObjects at some position
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   106
	in the passed view.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   107
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   108
      offset:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   109
	a clickOffset; drawing is offset by this amount
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   110
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   111
      extent:  
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   112
	a save extent; the size of the screen area that must be saved during
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   113
	the drag operation
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   114
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   115
      in:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   116
	initiating view
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   117
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   118
      at:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   119
	position where d&d operation starts
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   120
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   121
      atEnd:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   122
	a 4-arg block that is evaluated when the d&d is finished.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   123
	It gets the target view (or nil, for alien views), the targets
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   124
	view ID (needed if its an alien view), the screen position and the
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   125
	relative position within the target view of the drop as arguments.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   126
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   127
	For internal (ST/X) views, the dropBlock should perform
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   128
	a simple canDrop:/doDrop message.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   129
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   130
	For alien views, the Displays d&d functions can be used.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   131
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   132
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   133
    [author:]
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   134
	Claus Gittinger
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   135
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   136
    [see also:]
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   137
	DemoView1, DemoView2, ...
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   138
	SelectionInListView FileBrowser - for a concrete example
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   139
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   140
"
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   141
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   142
!
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   143
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   144
examples
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   145
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   146
  a button, which initiates dragging of a file-object
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   147
  Notice that this can be dropped into the launchers panel,
549
51c6f1d918c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
   148
  to open a fileBrowser on that directory ...
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   149
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   150
     |o top v|
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   151
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   152
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   153
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   154
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   155
		|o|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   156
		o := DropObject newFile:('/etc').
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   157
		DragAndDropManager startDrag:o from:v.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   158
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   159
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   160
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   161
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   162
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   163
  initiate a drag with some offset:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   164
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   165
     |o top v|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   166
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   167
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   168
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   169
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   170
		|o|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   171
		o := DropObject newFile:('.').
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   172
		DragAndDropManager startDrag:o from:v offset:10@10.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   173
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   174
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   175
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   176
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   177
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   178
  initiate a line drag:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   179
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   180
     |o top v endAction|
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   181
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   182
     endAction := [ :v :vID :sPos :vPos |
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   183
		    Transcript show:'end drag in '.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   184
		    v isNil ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   185
			Transcript show:'alien view'
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   186
		    ] ifFalse:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   187
			Transcript show:v
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   188
		    ].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   189
		    Transcript show:' at screen: '; show:sPos;
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   190
			       show:' in view: '; showCR:vPos
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   191
		].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   192
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   193
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   194
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   195
		DragAndDropManager 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   196
		    startLineDragIn:v at:10@10 atEnd:endAction.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   197
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   198
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   199
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   200
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   201
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   202
   more drag & drop; offset, displayObjects, ...
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   203
								[exBegin]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   204
    |dropObj topView pannel icon buttonAction addButton|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   205
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   206
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   207
    pannel  := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   208
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   209
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   210
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   211
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   212
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   213
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   214
    addButton := [:offset :label :dispObj| |button|
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   215
	button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   216
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   217
	button pressAction:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   218
	    DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   219
	    button turnOff.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   220
	]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   221
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   222
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   223
    addButton value:(0@-5)       value:'String'       value:'String'.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   224
    addButton value:#topLeft     value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   225
    addButton value:#topRight    value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   226
    addButton value:#bottomLeft  value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   227
    addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   228
    addButton value:#center      value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   229
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   230
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   231
    topView openWithExtent:200@200.
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   232
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   233
"
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   235
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   236
!DragAndDropManager class methodsFor:'initialization'!
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   237
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   238
initialize
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   239
    DragOriginatorQuerySignal := QuerySignal new.
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   240
    DragOffsetQuerySignal := QuerySignal new.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   241
    DragContextQuerySignal := QuerySignal new.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   242
    ActiveDragAndDropManagers := IdentityDictionary new.
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   243
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   244
    "
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   245
     self initialize
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   246
    "
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   247
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   248
    "Modified: 11.8.1997 / 00:54:21 / cg"
1420
418a8f90b7bc category change
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   249
! !
418a8f90b7bc category change
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   250
418a8f90b7bc category change
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   251
!DragAndDropManager class methodsFor:'instance creation'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   252
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   253
new
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   254
    ^ self basicNew initialize
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   255
! !
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   256
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   257
!DragAndDropManager class methodsFor:'Signal constants'!
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   258
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   259
dragContextQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   260
    ^ DragContextQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   261
!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   262
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   263
dragOffsetQuerySignal
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   264
    ^ DragOffsetQuerySignal
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   265
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   266
    "Created: 11.8.1997 / 00:54:10 / cg"
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   267
!
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   268
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   269
dragOriginatorQuerySignal
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   270
    ^ DragOriginatorQuerySignal
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   271
! !
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   272
1842
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   273
!DragAndDropManager class methodsFor:'defaults'!
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   274
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   275
autoScrollDelayTimeMs
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   276
    "time measured in milli-seconds the autoscroll task is delayed"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   277
1842
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   278
    ^ 200
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   279
! !
f033c7b344de compress buttonMotion events handling (look for outstanding events)
ca
parents: 1835
diff changeset
   280
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   281
!DragAndDropManager class methodsFor:'helpers'!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   282
2042
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   283
disabledFlag:aBoolean device:aDevice
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   284
    |activeManager|
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   285
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   286
    activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil.
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   287
    activeManager notNil ifTrue:[
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   288
        activeManager disabledFlag: aBoolean
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   289
    ].
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   290
!
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   291
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   292
postDraggingOnDevice:aDevice
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   293
    |activeManager|
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   294
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   295
    activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil.
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   296
    activeManager notNil ifTrue:[
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   297
        activeManager dragHandler postDragging
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   298
    ].
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   299
!
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   300
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   301
rereadSaveAreaOnDevice:aDevice
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   302
    |activeManager|
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   303
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   304
    activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil.
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   305
    activeManager notNil ifTrue:[
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   306
        activeManager dragHandler flushSaveArea; rereadSaveArea
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   307
    ].
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   308
!
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   309
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   310
saveDraw:aBlock device:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   311
    |activeManager|
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   312
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   313
    activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil.
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   314
    activeManager isNil ifTrue:[
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   315
        aBlock value
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   316
    ] ifFalse:[
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   317
        activeManager saveDraw:aBlock
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   318
    ].
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   319
! !
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   320
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   321
!DragAndDropManager class methodsFor:'queries'!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   322
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   323
isDragAndDropActiveOnDevice:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   324
    ^ ActiveDragAndDropManagers includesKey:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   325
! !
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   326
1776
79372ca563fc category
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   327
!DragAndDropManager class methodsFor:'simple start-drop source'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   328
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   329
startDragFrom:aView dropSource:aDropSource
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   330
    "start a drop at the current pointer position."
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   331
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   332
    ^ (self new) startDragFrom:aView dropSource:aDropSource
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   333
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   334
1776
79372ca563fc category
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   335
!DragAndDropManager class methodsFor:'simple start-generic'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   336
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   337
startDrag:draggableObjects from:aView
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   338
    "start a drop at the current pointer position"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   339
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   340
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   341
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   342
              offset:0@0
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   343
               atEnd:nil
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   344
             display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   345
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   346
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   347
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   348
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   349
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   350
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   351
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   352
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   353
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   354
        DragAndDropManager startDrag:(DropObject newFile:('.')) from:button.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   355
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   356
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   357
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   358
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   359
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   360
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   361
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   362
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   363
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   364
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   365
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   366
     the dropPoint in root-coordinates and the dropPoint within the targetView"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   367
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   368
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   369
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   370
              offset:0@0
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   371
               atEnd:aFourArgEndBlock
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   372
             display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   373
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   374
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   375
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   376
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   377
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   378
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   379
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   380
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   381
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   382
        DragAndDropManager startDrag:(DropObject newFile:('.'))
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   383
                                from:button
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   384
                               atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   385
                                        Transcript showCR:'target  view: ', targetView   printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   386
                                        Transcript showCR:'target    id: ', targetViewId printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   387
                                        Transcript showCR:'point screen: ', screenPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   388
                                        Transcript showCR:'point target: ', targetPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   389
                                     ].
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   390
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   391
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   392
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   393
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   394
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   395
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   396
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   397
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   398
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   399
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   400
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   401
     the dropPoint in root-coordinates and the dropPoint within the targetView"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   402
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   403
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   404
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   405
              offset:0@0
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   406
               atEnd:aFourArgEndBlock
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   407
             display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   408
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   409
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   410
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   411
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   412
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   413
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   414
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   415
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   416
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   417
        DragAndDropManager startDrag:(DropObject newFile:('.'))
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   418
                                from:button
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   419
                               atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   420
                                        Transcript showCR:'target  view: ', targetView   printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   421
                                        Transcript showCR:'target    id: ', targetViewId printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   422
                                        Transcript showCR:'point screen: ', screenPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   423
                                        Transcript showCR:'point target: ', targetPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   424
                                     ]
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   425
                             display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))).
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   426
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   427
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   428
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   429
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   430
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   431
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   432
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   433
startDrag:draggableObjects from:aView display:something
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   434
    "start a drop at the current pointer position"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   435
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   436
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   437
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   438
              offset:0@0
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   439
               atEnd:nil
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   440
             display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   441
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   442
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   443
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   444
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   445
    |dropObj topView pannel icon buttonAction addButton|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   446
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   447
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   448
    pannel  := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   449
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   450
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   451
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   452
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   453
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   454
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   455
    addButton := [:label :dispObj| |button|
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   456
        button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   457
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   458
        button pressAction:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   459
            DragAndDropManager startDrag:dropObj from:button display:dispObj.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   460
            button turnOff.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   461
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   462
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   463
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   464
    addButton value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   465
    addButton value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   466
    addButton value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   467
    addButton value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   468
    addButton value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   469
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   470
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   471
    topView openWithExtent:200@200.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   472
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   473
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   474
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   475
startDrag:draggableObjects from:aView offset:anOffset
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   476
    "start a drop at the current pointer position"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   477
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   478
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   479
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   480
              offset:anOffset
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   481
               atEnd:nil
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   482
             display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   483
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   484
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   485
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   486
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   487
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   488
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   489
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   490
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   491
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   492
        DragAndDropManager startDrag:(DropObject newFile:('.')) from:button offset:(-10 @ -10).
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   493
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   494
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   495
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   496
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   497
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   498
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   499
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   500
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   501
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   502
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   503
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   504
     the dropPoint in root-coordinates and the dropPoint within the targetView"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   505
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   506
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   507
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   508
              offset:anOffset
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   509
               atEnd:aFourArgEndBlock
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   510
             display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   511
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   512
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   513
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   514
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   515
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   516
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   517
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   518
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   519
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   520
        DragAndDropManager startDrag:(DropObject newFile:('.'))
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   521
                                from:button
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   522
                              offset:(-10 @ -10)
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   523
                               atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   524
                                        Transcript showCR:'target  view: ', targetView   printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   525
                                        Transcript showCR:'target    id: ', targetViewId printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   526
                                        Transcript showCR:'point screen: ', screenPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   527
                                        Transcript showCR:'point target: ', targetPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   528
                                     ].
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   529
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   530
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   531
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   532
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   533
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   534
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   535
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   536
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   537
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   538
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   539
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   540
     the dropPoint in root-coordinates and the dropPoint within the targetView"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   541
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   542
    |manager|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   543
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   544
    manager := self new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   545
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   546
    manager startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   547
                 from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   548
               offset:anOffset
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   549
                atEnd:aFourArgEndBlock
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   550
              display:something.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   551
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   552
    ^ manager
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   553
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   554
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   555
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   556
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   557
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   558
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   559
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   560
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   561
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   562
        DragAndDropManager startDrag:(DropObject newFile:('.'))
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   563
                                from:button
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   564
                              offset:(-10 @ -10)
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   565
                               atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   566
                                        Transcript showCR:'target  view: ', targetView   printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   567
                                        Transcript showCR:'target    id: ', targetViewId printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   568
                                        Transcript showCR:'point screen: ', screenPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   569
                                        Transcript showCR:'point target: ', targetPoint  printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   570
                                     ]
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   571
                             display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))).
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   572
        button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   573
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   574
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   575
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   576
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   577
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   578
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   579
startDrag:draggableObjects from:aView offset:anOffset display:something
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   580
    "start a drop at the current pointer position"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   581
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   582
    ^ self startDrag:draggableObjects
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   583
                from:aView
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   584
              offset:anOffset
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   585
               atEnd:nil
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   586
             display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   587
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   588
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   589
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   590
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   591
    |dropObj topView pannel icon buttonAction addButton|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   592
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   593
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   594
    pannel  := VerticalPanelView origin:(0.0 @ 0.0) corner:(1.0 @ 1.0) in:topView.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   595
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   596
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   597
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   598
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   599
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   600
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   601
    addButton := [:offset :label :dispObj| |button|
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   602
        button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   603
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   604
        button pressAction:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   605
            DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   606
            button turnOff.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   607
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   608
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   609
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   610
    addButton value:#topLeft     value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   611
    addButton value:#topRight    value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   612
    addButton value:#bottomLeft  value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   613
    addButton value:#bottomRight value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   614
    addButton value:#center      value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   615
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   616
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   617
    topView openWithExtent:200@200.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   618
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   619
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   620
1776
79372ca563fc category
Claus Gittinger <cg@exept.de>
parents: 1749
diff changeset
   621
!DragAndDropManager class methodsFor:'simple start-lines'!
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   622
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   623
startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   624
    "start a rubber-arrow-line dragging in aView at dragPoint.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   625
     When finished, evaluate the fourArgBlock with targetView,
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   626
     targetID, screenPosition and targetViewPosition as arguments"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   627
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   628
    ^ self new startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   629
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   630
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   631
EXAMPLE:
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   632
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   633
    |button|
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   634
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   635
    button := (Button label:'press me').
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   636
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   637
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   638
        button turnOff.
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   639
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   640
        DragAndDropManager startArrowDragIn:button 
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   641
                                         at:(button preferredExtent // 2)
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   642
                                      atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   643
                                                targetView isNil ifTrue:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   644
                                                    Transcript show:'alien view'
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   645
                                                ] ifFalse:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   646
                                                    Transcript showCR:'target: ', targetView printString
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   647
                                                ].
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   648
                                                Transcript showCR:'point screen: ', screenPoint printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   649
                                                Transcript showCR:'point target: ', targetPoint printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   650
                                            ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   651
     ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   652
     button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   653
"
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   654
!
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   655
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   656
startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   657
    "start a rubber-line dragging in aView at dragPoint.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   658
     When finished, evaluate the fourArgBlock with targetView,
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   659
     targetID, screenPosition and targetViewPosition as arguments"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   660
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   661
    ^ self new startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   662
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   663
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   664
EXAMPLE:
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   665
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   666
    |button|
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   667
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   668
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   669
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   670
    button pressAction:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   671
        button turnOff.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   672
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   673
        DragAndDropManager startLineDragIn:button 
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   674
                                        at:(button preferredExtent // 2)
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   675
                                     atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   676
                                               targetView isNil ifTrue:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   677
                                                   Transcript show:'alien view'
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   678
                                               ] ifFalse:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   679
                                                   Transcript showCR:'target: ', targetView printString
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   680
                                               ].
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   681
                                               Transcript showCR:'point screen: ', screenPoint printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   682
                                               Transcript showCR:'point target: ', targetPoint printString.
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   683
                                           ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   684
     ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   685
     button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   686
"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   687
! !
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   688
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   689
!DragAndDropManager class methodsFor:'translation'!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   690
2436
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   691
translatePointFromScreen:aPoint to:aView
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   692
    "translate a point from screen to view coordinates"
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   693
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   694
    |viewsDevice trans point offset|
2436
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   695
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   696
    aView isRootView ifTrue:[^ aPoint].
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   697
    viewsDevice := aView device.
2436
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   698
    "/
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   699
    "/ get device coordinates
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   700
    "/
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   701
    (trans := aView transformation) notNil ifTrue:[
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   702
        point := trans applyInverseTo:aPoint
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   703
    ] ifFalse:[
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   704
        point := aPoint
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   705
    ].
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   706
    "/
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   707
    "/ translate to screen
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   708
    "/
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   709
    offset := viewsDevice translatePoint:0@0 fromView:(viewsDevice rootView) toView:aView.
2436
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   710
    ^ offset + point
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   711
!
352e5205454e pass dropContext in dragHandler
Claus Gittinger <cg@exept.de>
parents: 2411
diff changeset
   712
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   713
translatePointFromScreen:aPoint toView:aView
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   714
    "translate a point from screen- to view coordinates"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   715
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   716
    |viewsDevice trans point offset|
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   717
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   718
    viewsDevice := aView device.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   719
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   720
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   721
    "/ translate to view
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   722
    "/
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   723
    offset := viewsDevice translatePoint:0@0 fromView:(viewsDevice rootView) toView:aView.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   724
    point := aPoint + offset.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   725
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   726
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   727
    "/ get device coordinates
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   728
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   729
    (trans := aView transformation) notNil ifTrue:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   730
        point := trans applyInverseTo:point
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   731
    ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   732
    ^ point
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   733
!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   734
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   735
translatePointToScreen:aPoint from:aView
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   736
    "translate a point from view- to screen coordinates"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   737
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   738
    |viewsDevice trans point offset|
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   739
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
   740
    aView isRootView ifTrue:[^ aPoint].
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   741
    viewsDevice := aView device.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   742
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   743
    "/ get device coordinates
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   744
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   745
    (trans := aView transformation) notNil ifTrue:[
3436
bf6858caeb31 class: DragAndDropManager
Claus Gittinger <cg@exept.de>
parents: 3344
diff changeset
   746
        point := trans transformPoint:aPoint
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   747
    ] ifFalse:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   748
        point := aPoint
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   749
    ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   750
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   751
    "/ translate to screen
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   752
    "/
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
   753
    offset := viewsDevice translatePoint:0@0 fromView:aView toView:(viewsDevice rootView).
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
   754
    ^ offset + point
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   755
! !
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   756
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   757
!DragAndDropManager methodsFor:'accessing'!
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   758
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   759
device
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   760
    "returns the device of the source view"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   761
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   762
    ^ dragView device
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   763
!
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   764
2042
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   765
disabledFlag
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   766
    ^ disabledFlag ? false
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   767
!
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   768
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   769
disabledFlag:something
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   770
    disabledFlag := something.
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   771
!
00fd3e50afdd Add disabled flag. If enabled (=true) the handling of button motion
ab
parents: 2025
diff changeset
   772
2013
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   773
dragHandler
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   774
    "returns the current active handler which is responsible for drawing ..."
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   775
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   776
    ^ handler
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   777
!
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   778
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   779
dragHandler:aNewHandler
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   780
    "set the active handler which is responsible for drawing ..."
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   781
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   782
    handler := aNewHandler.
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   783
!
5af91e0ed687 *** empty log message ***
ca
parents: 1939
diff changeset
   784
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   785
dropContext
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   786
    "return the current context"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   787
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   788
    ^ dropContext
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   789
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   790
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   791
dropObjects
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   792
    "return the current dropObject collection"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   793
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   794
    ^ dropContext dropObjects
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   795
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   796
    "Modified: 19.4.1997 / 10:19:06 / cg"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   797
!
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   798
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   799
dropObjects:aCollectionOfDropObjects
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   800
    "set the current dropObject collection"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   801
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   802
    ^ dropContext dropObjects:aCollectionOfDropObjects
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   803
!
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   804
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   805
font
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   806
    "returns the font of the source view"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   807
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   808
    ^ dragView font
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   809
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   810
2358
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
   811
giveFocusToTargetWidget:aBoolean
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
   812
    giveFocusToTargetWidget := aBoolean.
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
   813
!
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
   814
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
   815
isDisabled
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
   816
    ^ disabledFlag ? false
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
   817
!
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
   818
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   819
notifyEndOfDropAction: aNoneArgBlock
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   820
    "the action is triggered after the drop has finished"
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   821
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   822
     notifyEndOfDropAction := aNoneArgBlock.
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   823
!
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
   824
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   825
passiveAction:aBlockOrNil
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   826
    self removePassiveAction.
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   827
    aBlockOrNil notNil ifTrue:[
3302
b6d6a1db9a79 class: DragAndDropManager
Stefan Vogel <sv@exept.de>
parents: 3115
diff changeset
   828
        passiveAction := aBlockOrNil.
b6d6a1db9a79 class: DragAndDropManager
Stefan Vogel <sv@exept.de>
parents: 3115
diff changeset
   829
        Processor addTimedBlock:aBlockOrNil afterMilliseconds:100.
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   830
    ].
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   831
!
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   832
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   833
removePassiveAction
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   834
    passiveAction notNil ifTrue:[
3302
b6d6a1db9a79 class: DragAndDropManager
Stefan Vogel <sv@exept.de>
parents: 3115
diff changeset
   835
        Processor removeTimedBlock:passiveAction.
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   836
        passiveAction := nil.
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   837
    ].
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   838
!
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   839
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   840
sourceWidget
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   841
    ^ dragView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   842
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   843
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
   844
!DragAndDropManager methodsFor:'accessing-cursor'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   845
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   846
alienCursor:aCursorOrImage
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   847
    "set the cursor used for an alien widget; not an ST/X view"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   848
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   849
    aCursorOrImage isImage ifTrue:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   850
        alienCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   851
    ] ifFalse:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   852
        (aCursorOrImage isMemberOf:Cursor) ifTrue:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   853
            alienCursor := aCursorOrImage
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   854
        ] ifFalse:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   855
            "/
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   856
            "/ use disabled cursor
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   857
            "/
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   858
            alienCursor := nil
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   859
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   860
    ]
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   861
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   862
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   863
disabledCursor:aCursorOrImage
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   864
    "set the cursor for an ST/X view, which can not drop the objects"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   865
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   866
    aCursorOrImage isImage ifTrue:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   867
        disabledCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   868
    ] ifFalse:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   869
        (aCursorOrImage isMemberOf:Cursor) ifTrue:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   870
            disabledCursor := aCursorOrImage
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   871
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   872
    ]
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   873
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   875
enabledCursor:aCursorOrImage
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   876
    "set the cursor for an ST/X view, which can drop the objects"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   877
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   878
    aCursorOrImage isImage ifTrue:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   879
        enabledCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   880
    ] ifFalse:[
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   881
        (aCursorOrImage isMemberOf:Cursor) ifTrue:[
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   882
            enabledCursor := aCursorOrImage
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   883
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   884
    ]
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   885
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   886
2411
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   887
!DragAndDropManager methodsFor:'change & update'!
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   888
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   889
contentsWillChange
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   890
    "called by the dropTarget-widget if the contents will change during a
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   891
     dragAndDrop operation"
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   892
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   893
    handler notNil ifTrue:[
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   894
        handler dropTargetWillChange
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   895
    ]
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   896
! !
9cec069b6442 fix selection problems for default drag handler
ab
parents: 2410
diff changeset
   897
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
   898
!DragAndDropManager methodsFor:'dragging-drop source'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   899
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   900
startDragFrom:aView dropSource:aDropSource
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   901
    "start a drag at the current pointer position."
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   902
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   903
    ^ self startDragFrom:aView dropSource:aDropSource offset:#topLeft "/ #center
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   904
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   905
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   906
startDragFrom:aView dropSource:aDropSource offset:anOffset
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   907
    "start a drag at the current pointer position."
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   908
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   909
    dropContext dropSource:aDropSource.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   910
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   911
    ^ self startDrag:(aDropSource dropObjects)
1718
7da6bd953eb9 comments
Claus Gittinger <cg@exept.de>
parents: 1689
diff changeset
   912
                from:aView
7da6bd953eb9 comments
Claus Gittinger <cg@exept.de>
parents: 1689
diff changeset
   913
              offset:anOffset
7da6bd953eb9 comments
Claus Gittinger <cg@exept.de>
parents: 1689
diff changeset
   914
               atEnd:nil
7da6bd953eb9 comments
Claus Gittinger <cg@exept.de>
parents: 1689
diff changeset
   915
             display:(aDropSource displayObjects)
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   916
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   917
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
   918
!DragAndDropManager methodsFor:'dragging-easy startup'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   919
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   920
startDrag:draggableObjects from:aView 
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   921
    "start a drop at the current pointer position"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   922
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   923
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   924
        startDrag:draggableObjects
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   925
        from:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   926
        offset:0 @ 0
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   927
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   928
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   929
startDrag:draggableObjects from:aView display:something 
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   930
    "start a drop at the current pointer position."
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   931
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   932
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   933
        startDrag:draggableObjects
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   934
        from:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   935
        offset:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   936
        atEnd:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   937
        display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   938
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   939
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   940
startDrag:draggableObjects from:aView offset:anOffset 
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   941
    "start a drop at the current pointer position with an offset"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   942
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   943
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   944
        startDrag:draggableObjects
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   945
        from:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   946
        offset:anOffset
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   947
        atEnd:nil
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   948
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   949
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   950
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock 
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   951
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   952
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   953
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   954
     the dropPoint in root-coordinates and the dropPoint within the targetView"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   955
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   956
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   957
        startDrag:draggableObjects
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   958
        from:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   959
        offset:anOffset
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   960
        atEnd:aFourArgEndBlock
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
   961
        display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   962
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   963
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   964
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgBlock display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   965
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   966
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   967
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   968
     the dropPoint in root-coordinates and the dropPoint within the targetView."
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
   969
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   970
    |height width fontWdt offset ascent device dispObjs list space|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   971
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   972
    self dropObjects:draggableObjects.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   973
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   974
    self dropObjects size == 0 ifTrue:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   975
        ^ self
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   976
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   977
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   978
    device   := aView device.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   979
    space    := 1.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   980
    height   := space negated.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   981
    width    := 0.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   982
    fontWdt  := aView font width.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   983
    ascent   := aView font ascent.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   984
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   985
    (list := something) isNil ifTrue:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   986
        list := self dropObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   987
    ] ifFalse:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   988
        (list isCollection not or:[list isString]) ifTrue:[
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   989
            list := Array with:something
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   990
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   991
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   992
    dispObjs := OrderedCollection new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   993
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   994
    list do:[:el|
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   995
        |obj asc|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   996
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   997
        obj    := self displayObjectFor:el on:device.
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   998
        asc    := (obj respondsTo:#string) ifTrue:[ascent] ifFalse:[0].
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   999
        height := height + space.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1000
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1001
        dispObjs add:(Array with:obj with:(0 @ (height + asc))).
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1002
        width  := width max:(obj widthOn:aView).
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1003
        height := height + (obj heightOn:aView).
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1004
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1005
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1006
    anOffset isSymbol ifTrue:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1007
        offset := (0@0 extent:(width @ height)) perform:anOffset.
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1008
    ] ifFalse:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1009
        offset := anOffset ? (0@0).
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1010
    ].
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1011
    offset := offset rounded.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1012
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1013
    dispObjs do:[:el| el at:2 put:((el at:2) - offset) ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1014
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1015
    self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1016
        startOpaqueDrag:
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1017
            [:p :v|
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1018
                |cursor hX hY pDraw|
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1019
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1020
                cursor := dragView cursor.
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1021
                hX := cursor hotX.
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1022
                hY := cursor hotY.
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1023
                pDraw := p "- (hX@hY) + cursor extent".
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1024
                dispObjs do:[:el| 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1025
                    (el at:1) displayOn:v at:pDraw + (el at:2)
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1026
                ] 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1027
            ]
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1028
        offset:offset
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1029
        extent:width @ height
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1030
        in:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1031
        at:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1032
        atEnd:aFourArgBlock
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1033
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
  1034
    "Modified: / 31.3.1998 / 11:18:04 / cg"
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1035
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1036
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1037
startDrag:draggableObjects from:aView offset:anOffset display:something 
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1038
    "start a drop at the current pointer position."
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1039
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1040
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1041
        startDrag:draggableObjects
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1042
        from:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1043
        offset:anOffset
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1044
        atEnd:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1045
        display:something
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1046
! !
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1047
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  1048
!DragAndDropManager methodsFor:'dragging-generic'!
342
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
  1049
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1050
startGenericDrag:aTwoArgDragBlock in:aView at:p atEnd:aFourArgEndBlock 
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1051
    "start a generic (caller-provided drag);
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1052
     Here, an inverting drag is initiated (i.e. the drawing is undone
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1053
     by inverting again). See startOpaqueDrag for another variant.
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1054
     the dragBlock, aTwoArgDragBlock will be called with two args
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1055
     aPoint and a drawingGC, to perform the drawing at some dragPoint.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1056
     The drag starts in aView at point p.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1057
     When finished, the endAction is called with four args:
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1058
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1059
     the dropPoint in root-coordinates and the dropPoint within the targetView"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1060
    
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1061
    ^ self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1062
        startOpaqueDrag:aTwoArgDragBlock
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1063
        offset:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1064
        extent:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1065
        in:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1066
        at:nil
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1067
        atEnd:aFourArgEndBlock
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1068
!
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1069
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1070
startOpaqueDrag:aDragBlock offset:offs extent:anExtent in:aView at:aDummyPoint atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1071
    "start an opaque or generic opaque (caller-provided drag);
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1072
     opaque drag means, that the drawing cannot be undone by two inverting
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1073
     draws, but instead, the area under the dragged object must be saved
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1074
     and restored. The areas size to be saved/restored is passed in anExtent.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1075
     the dragBlock, aDragBlock will be called with up to three args aPoint, a
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1076
     drawingGC and the display objects, to perform the drawing at some dragPoint.
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1077
     The drag starts in aView at point p.
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1078
     When finished, the endAction is called with four args:
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1079
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1080
     the dropPoint in root-coordinates and the dropPoint within the targetView"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1081
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1082
    |handler numArgs dragBlock dobjs|
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1083
2927
49bd291d76e0 changed: #startOpaqueDrag:offset:extent:in:at:atEnd:
Claus Gittinger <cg@exept.de>
parents: 2825
diff changeset
  1084
    dragOffset := offs ? (0@0).
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1085
    numArgs    := aDragBlock numArgs.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1086
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1087
    numArgs == 3 ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1088
        dobjs := self dropObjects.
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1089
        dragBlock := [:p :v| aDragBlock value:p value:v value:dobjs ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1090
    ] ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1091
        numArgs == 1 ifTrue:[
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1092
            dragBlock := [:p :v| aDragBlock value:p ]
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1093
        ] ifFalse:[
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1094
            dragBlock := aDragBlock
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1095
        ]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1096
    ].
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1097
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1098
    anExtent isNil ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1099
        handler := DragHandler startGenericDrag:dragBlock.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1100
    ] ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1101
        handler := DragHandler startOpaqueDrag:dragBlock extent:anExtent offset:dragOffset.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1102
    ].
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1103
    self doStart:handler for:aView atEnd:aFourArgEndBlock.
2927
49bd291d76e0 changed: #startOpaqueDrag:offset:extent:in:at:atEnd:
Claus Gittinger <cg@exept.de>
parents: 2825
diff changeset
  1104
49bd291d76e0 changed: #startOpaqueDrag:offset:extent:in:at:atEnd:
Claus Gittinger <cg@exept.de>
parents: 2825
diff changeset
  1105
    "Modified: / 18-07-2011 / 09:38:21 / cg"
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1106
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1107
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  1108
!DragAndDropManager methodsFor:'dragging-lines'!
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1109
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1110
startArrowDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock 
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1111
    "start a line-drag of an arrow-line.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1112
     The drag starts in aView at point aStartPoint.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1113
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1114
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1115
     the dropPoint in root-coordinates and the dropPoint within the targetView"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1116
    
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1117
    |p|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1118
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1119
    p := self class translatePointToScreen:aStartPoint from:aView.
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1120
    self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1121
        doStart:(DragHandler startArrowDragAt:p)
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1122
        for:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1123
        atEnd:aFourArgEndBlock
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1124
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1125
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1126
startLineDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock 
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1127
    "start a line-drag of a normal line.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1128
     The drag starts in aView at point aStartPoint.
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1129
     When finished, the endAction is called with four args:
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1130
     the targetView, the targetViews windowID (useful, if its an alien view),
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1131
     the dropPoint in root-coordinates and the dropPoint within the targetView"
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1132
    
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1133
    |p|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1134
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1135
    p := self class translatePointToScreen:aStartPoint from:aView.
2652
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1136
    self 
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1137
        doStart:(DragHandler startLineDragAt:p)
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1138
        for:aView
4d7395b74cf0 formatting
Claus Gittinger <cg@exept.de>
parents: 2625
diff changeset
  1139
        atEnd:aFourArgEndBlock
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1140
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1141
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1142
!DragAndDropManager methodsFor:'drawing'!
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1143
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1144
displayObjectFor:anObject on:aDevice
2402
cf6437ff07d2 changed #displayObjectFor:on:
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
  1145
    "converts an object to a display object.
cf6437ff07d2 changed #displayObjectFor:on:
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
  1146
     CG (to CA): this is an ugly hack and must be fixed to be OO,
cf6437ff07d2 changed #displayObjectFor:on:
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
  1147
                 in sending something like #asDragAndDropDisplayObjectOn:aDevice
cf6437ff07d2 changed #displayObjectFor:on:
Claus Gittinger <cg@exept.de>
parents: 2358
diff changeset
  1148
                 to anObject, and doing all specific optimizations there."
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1149
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1150
    |obj s1 s2|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1151
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1152
    obj := (anObject respondsTo:#displayObject) ifTrue:[anObject displayObject]
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1153
                                               ifFalse:[anObject].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1154
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1155
    obj isString ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1156
        ^ obj
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1157
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1158
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1159
    MessageNotUnderstood 
2540
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1160
        ignoreNotUnderstoodOf:#onDevice: 
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1161
        in:[
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1162
            obj := obj onDevice:aDevice
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1163
        ].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1164
3725
3fb5cf9108cf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
  1165
    obj isLabelAndIcon ifTrue:[
1823
e2d9927c7488 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
  1166
        ^ obj
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1167
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1168
2540
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1169
    (obj class == MultiColListEntry) ifTrue:[
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1170
        s1 := obj colAt:1.
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1171
        s2 := obj colAt:2.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1172
2540
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1173
        s1 isImage ifTrue:[
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1174
            s2 isImage  ifTrue:[ ^ self displayObjectFor:(LabelAndIcon form:s1  image:s2) on:aDevice ].
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1175
            s2 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s1 string:s2) on:aDevice ].
3725
3fb5cf9108cf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
  1176
            ^ s1 onDevice:aDevice.
2540
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1177
        ].
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1178
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1179
        s2 isImage ifTrue:[
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1180
            s1 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s2 string:s1) on:aDevice ].
3725
3fb5cf9108cf #REFACTORING by stefan
Stefan Vogel <sv@exept.de>
parents: 3623
diff changeset
  1181
            ^ s2 onDevice:aDevice.
2540
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1182
        ].
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1183
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1184
        s1 isString ifTrue:[^ s1].
253ce2688c49 changed #displayObjectFor:on:
Stefan Vogel <sv@exept.de>
parents: 2485
diff changeset
  1185
        s2 isString ifTrue:[^ s2].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1186
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1187
1823
e2d9927c7488 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1776
diff changeset
  1188
    ^ obj
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1189
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1190
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1191
showDragging:items in:aView at:p
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1192
    "helper for dragging dragObjects: draw them all"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1193
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1194
    |offs|
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1195
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1196
    offs := 0.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1197
    items do:[:item |
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1198
        item displayOn:aView at:p + (0@offs).
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1199
        offs := offs + (item heightOn:self)
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1200
    ]
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1201
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1202
    "Modified: 19.4.1997 / 12:41:24 / cg"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1203
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1204
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1205
!DragAndDropManager methodsFor:'event catching'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1206
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1207
buttonMotion:buttonAndModifierState x:x y:y view:aView
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1208
    |device screenPoint oldWidget oldId oldPoint newId newWidget oldTarget newTarget 
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1209
     isDroppable cursor|
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1210
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1211
    self isDisabled ifTrue: [ ^ self ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1212
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1213
    escapePressed == true ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1214
        self removePassiveAction.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1215
        ^ self
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1216
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1217
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1218
    (dragView notNil and:[dragView sensor motionEventPending]) ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1219
        ^ self
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1220
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1221
    self removePassiveAction.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1222
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1223
    device := dragView device.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1224
    oldWidget  := dropContext targetWidget.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1225
    oldId  := dropContext targetId.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1226
    oldPoint  := dropContext rootPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1227
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1228
    screenPoint := self class translatePointToScreen:(x @ y) from:aView.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1229
    dropContext rootPoint:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1230
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1231
    newId := device viewIdFromPoint:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1232
    newWidget := device viewFromId:newId.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1233
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1234
    dropContext rootPoint:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1235
    dropContext targetWidget:newWidget id:newId.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1236
    handler dropContext:dropContext.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1237
    handler isInterestedInDropTarget ifFalse:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1238
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1239
        "/ line or arrow handler
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1240
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1241
        handler dragTo:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1242
        ^ self
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1243
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1244
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1245
    oldTarget := dropContext dropTarget.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1246
    newTarget := self doFindDropTargetIn:newWidget at:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1247
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1248
    newTarget ~= oldTarget ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1249
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1250
        "/ drop target changed: handler might restore the screen
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1251
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1252
        handler dropTargetWillChange.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1253
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1254
        oldTarget notNil ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1255
            "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1256
            "/ setup old context
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1257
            "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1258
            dropContext targetWidget:oldWidget id:oldId.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1259
            oldTarget leave:dropContext.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1260
            dropContext targetWidget:newWidget id:newId.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1261
        ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1262
        dropContext dropTarget:newTarget.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1263
        newTarget notNil ifTrue:[ newTarget enter:dropContext ]
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1264
    ] ifFalse:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1265
        dropContext dropTarget:newTarget
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1266
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1267
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1268
    "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1269
    "/ update the cursor
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1270
    "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1271
    (isDroppable := dropContext canDrop) ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1272
        cursor := enabledCursor
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1273
    ] ifFalse:[
2766
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1274
        dropContext isAlienView ifTrue:[
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1275
            cursor := alienCursor.
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1276
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1277
"/            className := Screen current getWindowClassName:newId.
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1278
"/            title := Screen current getWindowText:newId.
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1279
"/            cursor := enabledCursor.
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1280
        ] ifFalse:[
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1281
            cursor := disabledCursor
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1282
        ].
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1283
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1284
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1285
    dragView cursor:cursor now:true.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1286
    "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1287
    "/ test if droppable state changed
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1288
    "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1289
    canDrop == isDroppable ifFalse:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1290
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1291
        "/ droppable state changed: handler might restore the screen
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1292
        "/
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1293
        canDrop := isDroppable.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1294
        handler dropTargetWillChange
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1295
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1296
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1297
    newTarget notNil ifTrue:[ newTarget over:dropContext ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1298
    handler dragTo:screenPoint.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1299
!
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1300
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1301
buttonRelease:button x:x y:y view:aView
2063
dc16836d45dc code cleanup
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  1302
    |targetWidget|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1303
2739
408584de7150 preps for right-menu on buttonRelease
Claus Gittinger <cg@exept.de>
parents: 2652
diff changeset
  1304
    (button == 1) ifFalse:[
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1305
        ^ self
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1306
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1307
    self removePassiveAction.
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
  1308
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1309
    restoreBlock value.                 "/ restore context before start drag
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1310
2061
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1311
    escapePressed == true ifTrue:[^ self].
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1312
2063
dc16836d45dc code cleanup
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  1313
    targetWidget := dropContext targetWidget.
2061
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1314
    dropAction notNil ifTrue:[
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1315
        "/
2061
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1316
        "/ initiator wants to do it himself, manually.
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1317
        "/ Thus, no feedBack operation invoked.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1318
        "/
2063
dc16836d45dc code cleanup
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  1319
        dropAction value:(targetWidget)
2061
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1320
                   value:(dropContext targetId)
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1321
                   value:(dropContext rootPoint)
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1322
                   value:(dropContext targetPoint).
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1323
    ] ifFalse:[
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1324
        dropContext doDrop
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1325
    ].
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1326
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1327
    "/ UI feels better, if the focus is assigned to the target view,
f847cebf016f focus behavior when \"click-for-focus\" is on.
Claus Gittinger <cg@exept.de>
parents: 2046
diff changeset
  1328
    "/ if click-for-focus is on.
2062
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1329
    "/ CG: no - do it always
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1330
"/    UserPreferences current focusFollowsMouse == false ifTrue:[
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1331
"/        dropContext targetWidget wantsFocusWithButtonPress ifTrue:[
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1332
"/            dropContext targetWidget requestFocus    
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1333
"/        ].
54c1c37389a0 dropTarget takesFocus
Claus Gittinger <cg@exept.de>
parents: 2061
diff changeset
  1334
"/    ].
2358
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1335
    giveFocusToTargetWidget ifTrue:[
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1336
        (targetWidget notNil and:[targetWidget shown]) ifTrue:[
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1337
            targetWidget topView raise; activate.
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1338
            targetWidget takeFocus.    
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1339
        ].
2063
dc16836d45dc code cleanup
Claus Gittinger <cg@exept.de>
parents: 2062
diff changeset
  1340
    ].
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1341
!
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1342
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1343
escapePressed
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1344
    "handle the escape key"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1345
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1346
    | dropTarget |
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1347
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1348
    escapePressed ~~ true ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1349
        escapePressed := true.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1350
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1351
        dragView cursor:savedCursor now:true.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1352
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1353
        handler notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1354
            "/ restore handler
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1355
            dropTarget := dropContext dropTarget.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1356
            handler postDragging.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1357
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1358
            dropTarget notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1359
                "/ invoke leave operation
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1360
                dropTarget  leave:dropContext.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1361
                dropContext dropTarget:nil.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1362
            ].
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1363
        ].
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1364
        self triggerEndOfDropAction.
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1365
    ].
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1366
!
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1367
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1368
keyPress:aKey x:x y:y view:aView
2069
38bdcff6aa5c comment
Claus Gittinger <cg@exept.de>
parents: 2063
diff changeset
  1369
    "stop the drag operation, when the escape key is pressed"
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1370
2070
869e370ce441 comment
Claus Gittinger <cg@exept.de>
parents: 2069
diff changeset
  1371
    <resource: #keyboard (#Escape)>
869e370ce441 comment
Claus Gittinger <cg@exept.de>
parents: 2069
diff changeset
  1372
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1373
    escapePressed == true ifTrue:[ ^ self ].    "/ ignored, escaped was already pressed
1629
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1374
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1375
    aKey == #Escape ifTrue:[
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1376
        self escapePressed.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1377
    ].
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1378
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1379
    ((aKey == #Cmd) 
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1380
    or:[ (aKey == #Shift)
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1381
    or:[ (aKey == #Ctrl) ]]) ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1382
        self updateDragKind.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1383
        "/ invoke motion, to force a redraw (of the dropKind-indicator)
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1384
        self buttonMotion:nil x:x y:y view:aView    
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1385
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1386
!
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1387
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1388
keyRelease:aKey x:x y:y view:aView
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1389
    "redraw if shift, alt or ctrl key is released"
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1390
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1391
    <resource: #keyboard (#Escape)>
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1392
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1393
    ((aKey == #Cmd) 
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1394
    or:[ (aKey == #Shift)
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1395
    or:[ (aKey == #Ctrl) ]]) ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1396
        self updateDragKind.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1397
        "/ invoke motion, to force a redraw (of the dropKind-indicator)
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1398
        self buttonMotion:nil x:x y:y view:aView    
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1399
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1400
!
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1401
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1402
processAutoScroll
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1403
    "process an autoScroll event"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1404
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1405
    |targetWidget targetPoint|
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1406
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1407
    self isActive ifFalse:[^ self].
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1408
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1409
    dropContext isNil ifTrue:[ ^ self ].
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1410
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1411
    targetWidget := dropContext targetWidget.
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1412
    targetWidget isNil ifTrue:[ ^ self ].
1835
d6db8466019b bugfix in scrolling during drag & drop; test for isRootView
ca
parents: 1834
diff changeset
  1413
    targetWidget isRootView ifTrue:[ ^ self ].
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1414
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1415
    targetPoint := dropContext targetPoint.
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1416
    targetPoint isNil ifTrue:[ ^ self ].
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1417
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1418
    (targetWidget dragAutoScroll: dropContext) ifFalse:[
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1419
        ^ self
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1420
    ].
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1421
    self buttonMotion:256 x:(targetPoint x) y:(targetPoint y) view:targetWidget.
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1422
!
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1423
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1424
processEvent:event
2022
6508caa8bdba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1425
    "filter keyboard events.
6508caa8bdba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1426
     Return true, if I have eaten the event"
6508caa8bdba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2013
diff changeset
  1427
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1428
    |evView|
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1429
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1430
    restoreBlock isNil ifTrue:[^ false].        "/ should not happen
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1431
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1432
    evView := event view.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1433
    evView isNil ifTrue:[^ false].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1434
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1435
    event isInputEvent ifFalse:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1436
        ^ false
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1437
    ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1438
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1439
    event isKeyPressEvent ifTrue:[
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1440
        self keyPress:(event key) x:(event x) y:(event y) view:evView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1441
        ^ true
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1442
    ].
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1443
    event isKeyReleaseEvent ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1444
        self keyRelease:(event key) x:(event x) y:(event y) view:evView.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1445
        ^ true
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1446
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1447
    event isButtonMotionEvent ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1448
        self buttonMotion:(event state) x:(event x) y:(event y) view:evView.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1449
        ^ true
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1450
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1451
    event isButtonReleaseEvent ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1452
        self buttonRelease:(event button) x:(event x) y:(event y) view:evView.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1453
        ^ true
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1454
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1455
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1456
    ^ true
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1457
!
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1458
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1459
triggerEndOfDropAction
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1460
    "handle the escape key"
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1461
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1462
    |action|
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1463
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1464
    action := notifyEndOfDropAction.
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1465
    action isNil ifTrue:[ ^ self ].
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1466
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1467
    notifyEndOfDropAction := nil.
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1468
    action value.
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1469
!
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1470
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1471
updateDragKind
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1472
    "stop the drag operation, when the escape key is pressed"
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1473
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1474
    |screen dragType|
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1475
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1476
    dragType := DropContext dragTypeDefault.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1477
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1478
    screen := dragView device.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1479
    screen ctrlDown ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1480
        dragType := DropContext dragTypeCopy.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1481
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1482
    screen metaDown ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1483
        dragType := DropContext dragTypeLink.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1484
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1485
    screen shiftDown ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1486
        dragType := DropContext dragTypeMove.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1487
    ].
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1488
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1489
    dropContext dragType:dragType.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1490
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1491
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1492
!DragAndDropManager methodsFor:'initialization'!
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1493
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1494
initialize
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1495
    super initialize.
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1496
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1497
    dragOffset     := 0 @ 0.
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1498
    dropContext    := DropContext new manager:self.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1499
    alienCursor    := Cursor questionMark.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1500
    enabledCursor  := Cursor thumbsUp.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1501
    disabledCursor := Cursor thumbsDown.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1502
    canDrop        := false.
2358
7eca18445279 add #giveFocusToTargetWidget
ca
parents: 2259
diff changeset
  1503
    giveFocusToTargetWidget := true.
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1504
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1505
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1506
!DragAndDropManager methodsFor:'private'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1507
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1508
doDrop:aContext in:aWidget
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1509
    "old drop mechanism"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1510
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1511
    |point|
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1512
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1513
    DragContextQuerySignal answer:aContext do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1514
        DragOriginatorQuerySignal answer:dragView do:[
2255
074d16551e16 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2254
diff changeset
  1515
            DragOffsetQuerySignal answer:dragOffset do:[ 
074d16551e16 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2254
diff changeset
  1516
                |targetWidget targetPoint|
074d16551e16 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2254
diff changeset
  1517
2025
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1518
                targetWidget := aContext targetWidget.
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1519
                targetPoint  := aContext targetPoint.
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1520
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1521
                targetWidget == aWidget ifTrue:[
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1522
                    point := targetPoint.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1523
                ] ifFalse:[
2025
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1524
                    point := targetWidget originRelativeTo:aWidget.
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1525
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1526
                    point isNil ifTrue:[
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1527
                        point := 0@0.
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1528
                    ] ifFalse:[
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1529
                        point := point + targetPoint.
b40f8ad0d6fb bugfix: computing the drop point (see UIPainter)
ca
parents: 2022
diff changeset
  1530
                    ].
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1531
                    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1532
                    "/ FeedBack: set the widget which handles the drop
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1533
                    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1534
                    aContext targetWidget:aWidget id:(aWidget id).
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1535
                ].
2254
b120e73f9a76 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2133
diff changeset
  1536
                aWidget dropObjects:(aContext dropObjects) at:point
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1537
            ]
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1538
        ].
609
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1539
    ].
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1540
2255
074d16551e16 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2254
diff changeset
  1541
    "Modified: / 13-10-2006 / 17:52:56 / cg"
346
1612c23d9c5d pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1542
!
1612c23d9c5d pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1543
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1544
doFindDropTargetIn:aView at:aPoint
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1545
    "get the drop target for a view and source at a point or nil"
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1546
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1547
    |target|
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1548
2133
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1549
    aView isNil ifTrue:[ 
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1550
        ^ nil 
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1551
    ].
2485
50d5d6a67f44 *** empty log message ***
sr
parents: 2475
diff changeset
  1552
    aView isRootView ifTrue:[ 
50d5d6a67f44 *** empty log message ***
sr
parents: 2475
diff changeset
  1553
        ^ nil 
50d5d6a67f44 *** empty log message ***
sr
parents: 2475
diff changeset
  1554
    ].
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1555
2133
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1556
    "new mechanism to get a dropTarget"
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1557
    target := aView dropTarget.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1558
    target notNil ifTrue:[ 
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1559
        ^ target 
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1560
    ].
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1561
2133
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1562
    "old mechanism to get a dropTarget"
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1563
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1564
    (SignalSet
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1565
        with:DragContextQuerySignal
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1566
        with:DragOriginatorQuerySignal
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1567
        with:DragOffsetQuerySignal)
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1568
    handle:[:ex |
3115
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1569
        |signal|
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1570
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1571
        signal := ex creator.
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1572
        signal == DragContextQuerySignal ifTrue:[ ex proceedWith:dropContext].
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1573
        signal == DragOriginatorQuerySignal ifTrue:[ ex proceedWith:dragView].
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1574
        signal == DragOffsetQuerySignal ifTrue:[ ex proceedWith:dragOffset].
2133
0581d9906df0 common behavior for windows and unix:
Stefan Vogel <sv@exept.de>
parents: 2093
diff changeset
  1575
        self error:'unexpected query'.
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1576
    ] do:[
2823
bd8a57d5aa47 comment/format in: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2766
diff changeset
  1577
        |view app dobj|
1587
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1578
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1579
        view := aView.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1580
        dobj := dropContext dropObjects.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1581
        [   
2259
76b190967964 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
  1582
            (view canDrop:dropContext) ifTrue:[
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1583
                ^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1584
            ].
2259
76b190967964 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
  1585
            (view canDropObjects:dobj) ifTrue:[
76b190967964 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
  1586
                ^ (DropTarget receiver:view argument:nil dropSelector:#dropObjects:at:) oldDropAPI:true.
76b190967964 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
  1587
            ].
2823
bd8a57d5aa47 comment/format in: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2766
diff changeset
  1588
            view application ~~ app ifTrue:[
bd8a57d5aa47 comment/format in: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2766
diff changeset
  1589
                app := view application.
2825
e87c85566e08 changed: #doFindDropTargetIn:at: check for unspecified application
ca
parents: 2823
diff changeset
  1590
e87c85566e08 changed: #doFindDropTargetIn:at: check for unspecified application
ca
parents: 2823
diff changeset
  1591
                app notNil ifTrue:[
e87c85566e08 changed: #doFindDropTargetIn:at: check for unspecified application
ca
parents: 2823
diff changeset
  1592
                    (app canDropObjects:dobj) ifTrue:[
e87c85566e08 changed: #doFindDropTargetIn:at: check for unspecified application
ca
parents: 2823
diff changeset
  1593
                        ^ (DropTarget receiver:app argument:nil dropSelector:#dropObjects:at:) oldDropAPI:true.
e87c85566e08 changed: #doFindDropTargetIn:at: check for unspecified application
ca
parents: 2823
diff changeset
  1594
                    ].
2823
bd8a57d5aa47 comment/format in: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2766
diff changeset
  1595
                ].
bd8a57d5aa47 comment/format in: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2766
diff changeset
  1596
            ].
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1597
            (view := view superView) notNil
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1598
        ] whileTrue.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1599
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1600
    ^ nil
2255
074d16551e16 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2254
diff changeset
  1601
2259
76b190967964 drag and drop cleanup
Claus Gittinger <cg@exept.de>
parents: 2255
diff changeset
  1602
    "Modified: / 13-10-2006 / 18:21:43 / cg"
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1603
!
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1604
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1605
doStart:aHandler for:aView atEnd:aFourArgEndBlock
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1606
    "setup a handler and a restore block"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1607
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1608
    |viewsDevice lastActive windowGroup screenPoint|
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1609
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1610
    viewsDevice := aView device.
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1611
    lastActive := ActiveDragAndDropManagers at:viewsDevice ifAbsent:nil.
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1612
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1613
    lastActive notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1614
        "/ self error:'oops - two dnd managers active' mayProceed:true.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1615
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1616
        lastActive forceGiveUp.
1939
f72ff9a773e5 print -> infoPrint
Claus Gittinger <cg@exept.de>
parents: 1842
diff changeset
  1617
        'DragAndDropManager [info]: oops - two dnd managers active' infoPrintCR.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1618
    ].
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1619
    ActiveDragAndDropManagers at:viewsDevice put:self.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1620
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1621
    dropContext sourceWidget:aView.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1622
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1623
    dragOffset  isNil ifTrue:[ dragOffset  := 0 @ 0 ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1624
    alienCursor isNil ifTrue:[ alienCursor := disabledCursor ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1625
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1626
    dragView      := aView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1627
    dropAction    := aFourArgEndBlock.
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1628
    windowGroup   := aView windowGroup.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1629
    handler       := aHandler.
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1630
    escapePressed := false.
609
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1631
1162
0539b64679ce set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1632
    dropContext dragHandler:aHandler.
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1633
1689
5aae4c617ffd obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents: 1686
diff changeset
  1634
    savedCursor := dragView cursor.
5aae4c617ffd obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents: 1686
diff changeset
  1635
    windowGroup addPreEventHook:self.
5aae4c617ffd obsoleted preEventHook and postEventHook in windowGroup
Claus Gittinger <cg@exept.de>
parents: 1686
diff changeset
  1636
    windowGroup addPostEventHook:self.
1162
0539b64679ce set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1637
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1638
    restoreBlock := 
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1639
        [
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1640
            restoreBlock := nil.
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1641
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1642
            autoScrollTask notNil ifTrue:[
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1643
                autoScrollTask terminate.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1644
                autoScrollTask := nil.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1645
            ].
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1646
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1647
            ActiveDragAndDropManagers removeKey:viewsDevice ifAbsent:nil.
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1648
            escapePressed ifFalse:[ aHandler postDragging ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1649
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1650
            windowGroup removePreEventHook:self.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1651
            windowGroup removePostEventHook:self.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1652
            dragView cursor:savedCursor.
2410
95115083fd32 *** empty log message ***
ca
parents: 2402
diff changeset
  1653
2625
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1654
            self triggerEndOfDropAction.
3ad1c3a78c8d change back the cursor, when escaping;
Claus Gittinger <cg@exept.de>
parents: 2540
diff changeset
  1655
        ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1656
    aHandler preDraggingIn:dragView.
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1657
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1658
    "/ must wait for all pending motion events to arrive, and ignore them
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1659
    viewsDevice sync.        
1749
1f58fbcd4b96 Use SynchronousWindoeSensor if no windowGroup
Stefan Vogel <sv@exept.de>
parents: 1718
diff changeset
  1660
    dragView sensor flushMotionEventsFor:nil.
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1661
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1662
    autoScrollTask := 
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1663
        [
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1664
            [   |sensor|
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1665
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1666
                sensor := windowGroup sensor.
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1667
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1668
                [ self isActive ] whileTrue:[
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1669
                    Delay waitForMilliseconds:(self class autoScrollDelayTimeMs).
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1670
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1671
                    self isActive ifTrue:[
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1672
                        sensor pushUserEvent:#processAutoScroll for:self.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1673
                    ].
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1674
                ].
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1675
            ]ensure:[
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1676
                autoScrollTask := nil.
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1677
            ]
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1678
         ] newProcess.
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1679
2091
0fdd1265fd82 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2078
diff changeset
  1680
    autoScrollTask priority:(Processor userSchedulingPriority).
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1681
    autoScrollTask name:'Drag-AutoScroll'.
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1682
    autoScrollTask resume.
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1683
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1684
    "/ start with a first draw at the current mouse position
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1685
    screenPoint := viewsDevice pointerPosition.
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1686
    self buttonMotion:1 x:(screenPoint x) y:(screenPoint y) view:(viewsDevice rootView).
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1687
!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1688
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1689
forceGiveUp
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1690
    "called if the DragAndDropManager no longer should be
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1691
     active; a second one is started"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1692
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1693
    self escapePressed.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1694
    self removePassiveAction.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1695
    restoreBlock value.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1696
!
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1697
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1698
isActive
2078
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1699
    "returns true if a drag operation is active"
152102d2d8a0 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 2070
diff changeset
  1700
1834
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1701
    restoreBlock isNil ifTrue:[ ^ false ].
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1702
    ^ escapePressed ~~ true
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1703
!
fe5dd53e3a80 support autoScroll during drag operation
ca
parents: 1823
diff changeset
  1704
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1705
saveDraw:aBlock
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1706
    handler postDragging.
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1707
    aBlock value.
1638
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1708
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1709
    escapePressed == true ifFalse:[
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1710
        "/ reread and show drag items
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1711
        handler rereadSaveArea.
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1712
        handler restoreFromSaveArea.
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1713
    ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1714
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1715
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1716
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1717
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1718
version
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1719
    ^ '$Header$'
2766
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1720
!
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1721
27e34fa6ecfe changed: #buttonMotion:x:y:view:
Claus Gittinger <cg@exept.de>
parents: 2739
diff changeset
  1722
version_CVS
3623
9ddec519a3c6 class: DebugView
Claus Gittinger <cg@exept.de>
parents: 3436
diff changeset
  1723
    ^ '$Header$'
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1724
! !
1629
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1725
3115
a675e9962acc use #creator instead of #signal
Claus Gittinger <cg@exept.de>
parents: 2927
diff changeset
  1726
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1727
DragAndDropManager initialize!