DragAndDropManager.st
author ca
Tue, 21 Jan 2003 08:23:12 +0100
changeset 1686 fe4a13681941
parent 1685 82350f572e2f
child 1689 5aae4c617ffd
permissions -rw-r--r--
add eventHooks on windowGroup
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
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    12
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    13
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
    14
"{ Package: 'stx:libview2' }"
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
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
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
    19
		passiveAction'
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
    20
	classVariableNames:'DragContextQuerySignal DragOriginatorQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
    21
		DragOffsetQuerySignal ActiveDragAndDropManagers'
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
    22
	poolDictionaries:''
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
    23
	category:'Interface-DragAndDrop'
342
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
    24
!
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
    25
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    26
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
    27
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    28
copyright
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    29
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    30
 COPYRIGHT (c) 1996 by eXept Software AG / Claus Gittinger
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    31
	      All Rights Reserved
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    32
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    33
 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
    34
 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
    35
 inclusion of the above copyright notice.   This software may not
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    36
 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
    37
 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
    38
 hereby transferred.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    39
"
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
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    43
documentation
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    44
"
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    45
    this class provides low-level drag & drop mechanisms.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
    46
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    47
    Easy to use interface interfaces:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    48
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    49
    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
    50
    when a selection is moved (for example, SelectionInListView can
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    51
    be initializd to do so). 
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    52
    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
    53
    and starts the drag operation with:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    54
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    55
	DragAndDropManager startDrag:collectionOfDragObjects from:aView.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    56
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    57
    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
    58
    into the target view.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    59
    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
    60
    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
    61
    is shown for alien views (which means: we dont know).
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    62
    Alien view drop is supported (but no 'canDrop' query).
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    63
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    64
    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
    65
    provided:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    66
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    67
	DragAndDropManager
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    68
		startLineDragIn:aView at:position
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    69
		atEnd:aFourArgEndBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    70
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    71
    and:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    72
	DragAndDropManager
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    73
		startArrowDragIn:aView at:position
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    74
		atEnd:aFourArgEndBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    75
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    76
    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
    77
    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
    78
    on the screen and within the target view as arguments.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    79
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
    Expert interface:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    82
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    83
    More control over the dragging (i.e. the drawing procedure)
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
    84
    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
    85
        
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    86
	aDragAndDropMgr := DragAndDropManager new.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    87
	aDragAndDropMgr dropObjects:(self collectionOfDragObjects).
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    88
	aDragAndDropMgr 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    89
	    startOpaqueDrag:[:aPoint :aView :dropObjects | 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    90
				self 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    91
				    showDragging:dropObjects
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    92
				    in:aView 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    93
				    at:aPoint - (xOffset@0)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    94
			    ]
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    95
	    offset:clickOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    96
	    extent:saveUnderExtent
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    97
	    in:self
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    98
	    at:clickPoint
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
    99
	    atEnd:[:v :vId :posScreen :posView | ... ]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   100
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   101
    the arguments are:
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   102
      startOpaqueDrag:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   103
	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
   104
	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
   105
	in the passed view.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   106
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   107
      offset:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   108
	a clickOffset; drawing is offset by this amount
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   109
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   110
      extent:  
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   111
	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
   112
	the drag operation
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   113
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   114
      in:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   115
	initiating view
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   116
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   117
      at:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   118
	position where d&d operation starts
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   119
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   120
      atEnd:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   121
	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
   122
	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
   123
	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
   124
	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
   125
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   126
	For internal (ST/X) views, the dropBlock should perform
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   127
	a simple canDrop:/doDrop message.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   128
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   129
	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
   130
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   131
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   132
    [author:]
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   133
	Claus Gittinger
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   134
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   135
    [see also:]
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   136
	DemoView1, DemoView2, ...
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   137
	SelectionInListView FileBrowser - for a concrete example
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   138
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   139
"
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
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   143
examples
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   144
"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   145
  a button, which initiates dragging of a file-object
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   146
  Notice that this can be dropped into the launchers panel,
549
51c6f1d918c2 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 548
diff changeset
   147
  to open a fileBrowser on that directory ...
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   148
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   149
     |o top v|
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   150
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   151
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   152
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   153
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   154
		|o|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   155
		o := DropObject newFile:('/etc').
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   156
		DragAndDropManager startDrag:o from:v.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   157
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   158
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   159
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   160
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   161
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   162
  initiate a drag with some offset:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   163
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   164
     |o top v|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   165
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   166
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   167
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   168
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   169
		|o|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   170
		o := DropObject newFile:('.').
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   171
		DragAndDropManager startDrag:o from:v offset:10@10.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   172
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   173
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   174
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   175
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   176
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   177
  initiate a line drag:
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   178
								[exBegin]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   179
     |o top v endAction|
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   180
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   181
     endAction := [ :v :vID :sPos :vPos |
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   182
		    Transcript show:'end drag in '.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   183
		    v isNil ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   184
			Transcript show:'alien view'
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   185
		    ] ifFalse:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   186
			Transcript show:v
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   187
		    ].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   188
		    Transcript show:' at screen: '; show:sPos;
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   189
			       show:' in view: '; showCR:vPos
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   190
		].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   191
     top := StandardSystemView new.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   192
     v := Button label:'press for drag' in:top.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   193
     v pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   194
		DragAndDropManager 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   195
		    startLineDragIn:v at:10@10 atEnd:endAction.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   196
		v turnOff
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   197
	      ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   198
     top openWithExtent:200@200
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   199
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   200
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   201
   more drag & drop; offset, displayObjects, ...
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   202
								[exBegin]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   203
    |dropObj topView pannel icon buttonAction addButton|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   204
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   205
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   206
    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
   207
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   208
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   209
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   210
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   211
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   212
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   213
    addButton := [:offset :label :dispObj| |button|
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   214
	button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   215
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   216
	button pressAction:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   217
	    DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   218
	    button turnOff.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   219
	]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   220
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   221
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   222
    addButton value:(0@-5)       value:'String'       value:'String'.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   223
    addButton value:#topLeft     value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   224
    addButton value:#topRight    value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   225
    addButton value:#bottomLeft  value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   226
    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
   227
    addButton value:#center      value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   228
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   229
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   230
    topView openWithExtent:200@200.
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   231
								[exEnd]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   232
"
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   233
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
   234
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   235
!DragAndDropManager class methodsFor:'initialization'!
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   236
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   237
initialize
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   238
    DragOriginatorQuerySignal := QuerySignal new.
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   239
    DragOffsetQuerySignal := QuerySignal new.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   240
    DragContextQuerySignal := QuerySignal new.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   241
    ActiveDragAndDropManagers := IdentityDictionary new.
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   242
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   243
    "
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   244
     self initialize
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   245
    "
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   246
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   247
    "Modified: 11.8.1997 / 00:54:21 / cg"
1420
418a8f90b7bc category change
Claus Gittinger <cg@exept.de>
parents: 1397
diff changeset
   248
! !
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
!DragAndDropManager class methodsFor:'instance creation'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   251
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   252
new
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   253
    ^ self basicNew initialize
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   254
! !
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   255
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   256
!DragAndDropManager class methodsFor:'Signal constants'!
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   257
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   258
dragContextQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   259
    ^ DragContextQuerySignal
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   260
!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   261
680
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   262
dragOffsetQuerySignal
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
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   265
    "Created: 11.8.1997 / 00:54:10 / cg"
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   266
!
6157661790fd keep dragOffset - provide querySignal
Claus Gittinger <cg@exept.de>
parents: 628
diff changeset
   267
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   268
dragOriginatorQuerySignal
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   269
    ^ DragOriginatorQuerySignal
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   270
! !
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
   271
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   272
!DragAndDropManager class methodsFor:'helpers'!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   273
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   274
saveDraw:aBlock device:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   275
    |activeManager|
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   276
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   277
    activeManager := ActiveDragAndDropManagers at:aDevice ifAbsent:nil.
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   278
    activeManager isNil ifTrue:[
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   279
        aBlock value
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   280
    ] ifFalse:[
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   281
        activeManager saveDraw:aBlock
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   282
    ].
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   283
! !
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   284
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   285
!DragAndDropManager class methodsFor:'queries'!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   286
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   287
isDragAndDropActiveOnDevice:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   288
    ^ ActiveDragAndDropManagers includesKey:aDevice
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   289
! !
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
   290
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   291
!DragAndDropManager class methodsFor:'simple start - drop source'!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   292
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   293
startDragFrom:aView dropSource:aDropSource
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   294
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   295
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   296
    ^ (self new) startDragFrom:aView dropSource:aDropSource
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   297
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   298
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   299
!DragAndDropManager class methodsFor:'simple start - generic'!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   300
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   301
startDrag:draggableObjects from:aView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   302
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   303
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   304
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   305
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   306
	      offset:0@0
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   307
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   308
	     display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   309
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   310
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   311
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   312
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   313
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   314
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   315
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   316
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   317
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   318
	DragAndDropManager startDrag:(DropObject newFile:('.')) from:button.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   319
	button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   320
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   321
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   322
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   323
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   324
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   325
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   326
startDrag:draggableObjects from:aView atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   327
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   328
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   329
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   330
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   331
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   332
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   333
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   334
	      offset:0@0
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   335
	       atEnd:aFourArgEndBlock
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   336
	     display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   337
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   338
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   339
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   340
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   341
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   342
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   343
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   344
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   345
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   346
	DragAndDropManager startDrag:(DropObject newFile:('.'))
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   347
				from:button
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   348
			       atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   349
					Transcript showCR:'target  view: ', targetView   printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   350
					Transcript showCR:'target    id: ', targetViewId printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   351
					Transcript showCR:'point screen: ', screenPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   352
					Transcript showCR:'point target: ', targetPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   353
				     ].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   354
	button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   355
    ].
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
    button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   358
"
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 display:something
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),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   366
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   367
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   368
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   369
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   370
	      offset:0@0
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   371
	       atEnd:aFourArgEndBlock
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   372
	     display:something
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:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   382
	DragAndDropManager startDrag:(DropObject newFile:('.'))
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   383
				from:button
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   384
			       atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   385
					Transcript showCR:'target  view: ', targetView   printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   386
					Transcript showCR:'target    id: ', targetViewId printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   387
					Transcript showCR:'point screen: ', screenPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   388
					Transcript showCR:'point target: ', targetPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   389
				     ]
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   390
			     display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))).
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   391
	button turnOff
874
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   394
    button openAt:100@100
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   398
startDrag:draggableObjects from:aView display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   399
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   400
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   401
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   402
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   403
	      offset:0@0
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   404
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   405
	     display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   406
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   407
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   408
EXAMPLE:
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
    |dropObj topView pannel icon buttonAction addButton|
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
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   413
    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
   414
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   415
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   416
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   417
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   418
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   419
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   420
    addButton := [:label :dispObj| |button|
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   421
	button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   422
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   423
	button pressAction:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   424
	    DragAndDropManager startDrag:dropObj from:button display:dispObj.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   425
	    button turnOff.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   426
	]
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
    addButton value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   430
    addButton value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   431
    addButton value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   432
    addButton value:'LabelAndIcon' value:(LabelAndIcon icon:icon string:'Label & Icon').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   433
    addButton value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   434
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   435
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   436
    topView openWithExtent:200@200.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   437
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   438
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   439
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   440
startDrag:draggableObjects from:aView offset:anOffset
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   441
    "start a drop at the current pointer position
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
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   444
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   445
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   446
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   447
	     display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   448
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   449
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   450
EXAMPLE:
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
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   453
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   454
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   455
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   456
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   457
	DragAndDropManager startDrag:(DropObject newFile:('.')) from:button offset:(-10 @ -10).
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   458
	button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   459
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   460
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   461
    button openAt:100@100
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
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   465
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   466
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   467
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   468
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   469
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   470
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   471
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   472
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   473
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   474
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   475
	       atEnd:aFourArgEndBlock
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   476
	     display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   477
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   478
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   479
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   480
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   481
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   482
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   483
    button := (Button label:'press me').
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
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   486
	DragAndDropManager startDrag:(DropObject newFile:('.'))
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   487
				from:button
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   488
			      offset:(-10 @ -10)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   489
			       atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   490
					Transcript showCR:'target  view: ', targetView   printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   491
					Transcript showCR:'target    id: ', targetViewId printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   492
					Transcript showCR:'point screen: ', screenPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   493
					Transcript showCR:'point target: ', targetPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   494
				     ].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   495
	button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   496
    ].
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
    button openAt:100@100
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   501
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   502
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   503
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   504
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   505
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   506
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   507
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   508
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   509
    |manager|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   510
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   511
    manager := self new.
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
    manager startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   514
		 from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   515
	       offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   516
		atEnd:aFourArgEndBlock
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   517
	      display:something.
874
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
    ^ manager
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   520
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   521
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   522
EXAMPLE:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   523
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   524
    |button|
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   525
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   526
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   527
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   528
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   529
	DragAndDropManager startDrag:(DropObject newFile:('.'))
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   530
				from:button
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   531
			      offset:(-10 @ -10)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   532
			       atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   533
					Transcript showCR:'target  view: ', targetView   printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   534
					Transcript showCR:'target    id: ', targetViewId printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   535
					Transcript showCR:'point screen: ', screenPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   536
					Transcript showCR:'point target: ', targetPoint  printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   537
				     ]
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   538
			     display:(Array with:'String' with:(Image fromFile:('xpmBitmaps/QUESTION3.xpm'))).
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   539
	button turnOff
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   540
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   541
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   542
    button openAt:100@100
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
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   547
startDrag:draggableObjects from:aView offset:anOffset display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   548
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   549
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   550
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   551
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   552
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   553
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   554
	     display:something
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   555
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
EXAMPLE:
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
    |dropObj topView pannel icon buttonAction addButton|
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
    topView := StandardSystemView new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   562
    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
   563
    pannel  horizontalLayout:#fit.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   564
    pannel  verticalLayout:#fitSpace.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   565
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   566
    icon    := Image fromFile:('xpmBitmaps/QUESTION3.xpm').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   567
    dropObj := DropObject newFile:('.').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   568
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   569
    addButton := [:offset :label :dispObj| |button|
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   570
	button := Button label:label in:pannel.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   571
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   572
	button pressAction:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   573
	    DragAndDropManager startDrag:dropObj from:button offset:offset display:dispObj.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   574
	    button turnOff.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   575
	]
874
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
    addButton value:#topLeft     value:'String'       value:'String'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   579
    addButton value:#topRight    value:'Text'         value:(Text string:'hello' emphasis:#bold).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   580
    addButton value:#bottomLeft  value:'Icon'         value:icon.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   581
    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
   582
    addButton value:#center      value:'Mixed'        value:(Array with:'String' with:icon).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   583
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   584
    topView label:'Drag & Drop'.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   585
    topView openWithExtent:200@200.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   586
"
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   590
!DragAndDropManager class methodsFor:'simple start - lines'!
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   591
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   592
startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   593
    "start a rubber-arrow-line dragging in aView at dragPoint.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   594
     When finished, evaluate the fourArgBlock with targetView,
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   595
     targetID, screenPosition and targetViewPosition as arguments
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   596
    "
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   597
    ^ self new startArrowDragIn:aView at:dragPoint atEnd:aFourArgBlock
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   598
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   599
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   600
EXAMPLE:
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   601
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   602
    |button|
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   603
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   604
    button := (Button label:'press me').
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   605
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   606
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   607
	button turnOff.
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   608
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   609
	DragAndDropManager startArrowDragIn:button 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   610
					 at:(button preferredExtent // 2)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   611
				      atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   612
						targetView isNil ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   613
						    Transcript show:'alien view'
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   614
						] ifFalse:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   615
						    Transcript showCR:'target: ', targetView printString
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   616
						].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   617
						Transcript showCR:'point screen: ', screenPoint printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   618
						Transcript showCR:'point target: ', targetPoint printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   619
					    ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   620
     ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   621
     button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   622
"
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   623
!
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   624
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   625
startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   626
    "start a rubber-line dragging in aView at dragPoint.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   627
     When finished, evaluate the fourArgBlock with targetView,
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   628
     targetID, screenPosition and targetViewPosition as arguments
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   629
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   630
    ^ self new startLineDragIn:aView at:dragPoint atEnd:aFourArgBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   631
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   632
"
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   633
EXAMPLE:
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   634
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   635
    |button|
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   636
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   637
    button := (Button label:'press me').
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   638
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   639
    button pressAction:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   640
	button turnOff.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   641
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   642
	DragAndDropManager startLineDragIn:button 
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   643
					at:(button preferredExtent // 2)
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   644
				     atEnd:[:targetView :targetViewId :screenPoint :targetPoint|
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   645
					       targetView isNil ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   646
						   Transcript show:'alien view'
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   647
					       ] ifFalse:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   648
						   Transcript showCR:'target: ', targetView printString
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   649
					       ].
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   650
					       Transcript showCR:'point screen: ', screenPoint printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   651
					       Transcript showCR:'point target: ', targetPoint printString.
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   652
					   ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   653
     ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   654
     button openAt:100@100
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   655
"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   656
! !
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   657
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   658
!DragAndDropManager class methodsFor:'translation'!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   659
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   660
translatePointFromScreen:aPoint toView:aView
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   661
    "translate a point to screen
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   662
    "
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   663
    |device trans point offset|
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   664
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   665
    device := aView device.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   666
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   667
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   668
    "/ translate to view
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   669
    "/
1517
5f4d38273014 use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   670
    offset := device translatePoint:0@0 fromView:(device rootView) toView:aView.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   671
    point := aPoint + offset.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   672
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   673
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   674
    "/ get device coordinates
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   675
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   676
    (trans := aView transformation) notNil ifTrue:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   677
        point := trans applyInverseTo:point
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   678
    ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   679
    ^ point
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   680
!
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   681
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   682
translatePointToScreen:aPoint from:aView
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   683
    "translate a point to screen
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   684
    "
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   685
    |device trans point offset|
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   686
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
   687
    aView isRootView ifTrue:[^ aPoint].
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   688
    device := aView device.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   689
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   690
    "/ get device coordinates
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   691
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   692
    (trans := aView transformation) notNil ifTrue:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   693
        point := trans applyTo:aPoint
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   694
    ] ifFalse:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   695
        point := aPoint
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   696
    ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   697
    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   698
    "/ translate to screen
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   699
    "/
1517
5f4d38273014 use new #translatePoint:fromView:toView:
Claus Gittinger <cg@exept.de>
parents: 1512
diff changeset
   700
    offset := device translatePoint:0@0 fromView:aView toView:(device rootView).
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
   701
    ^ offset + point
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   702
! !
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
   703
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   704
!DragAndDropManager methodsFor:'accessing'!
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   705
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   706
device
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   707
    "returns the device of the source view
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   708
    "
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   709
    ^ dragView device
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   710
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   711
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   712
!
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   713
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   714
dropContext
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   715
    "return the current context
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   716
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   717
    ^ dropContext
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   718
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   719
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   720
dropObjects
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   721
    "return the current dropObject collection"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   722
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   723
    ^ dropContext dropObjects
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   724
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   725
    "Modified: 19.4.1997 / 10:19:06 / cg"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   726
!
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   727
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   728
dropObjects:aCollectionOfDropObjects
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   729
    "set the current dropObject collection"
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
   730
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   731
    ^ dropContext dropObjects:aCollectionOfDropObjects
861
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   732
!
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   733
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   734
font
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   735
    "returns the font of the source view
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   736
    "
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   737
    ^ dragView font
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   738
10bbb13fcb05 add more simple drag & drop functionality:
ca
parents: 680
diff changeset
   739
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   740
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   741
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   742
passiveAction:aBlockOrNil
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   743
    self removePassiveAction.
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   744
    aBlockOrNil notNil ifTrue:[
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   745
        passiveAction := Processor addTimedBlock:aBlockOrNil afterMilliseconds:100
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   746
    ].
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   747
!
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   748
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   749
removePassiveAction
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   750
    passiveAction notNil ifTrue:[
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   751
        Processor removeTimeoutWithID:passiveAction.
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   752
        passiveAction := nil.
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   753
    ].
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   754
!
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
   755
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   756
sourceWidget
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   757
    ^ dragView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   758
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   759
1397
47ac1d3e1df1 category changes
Claus Gittinger <cg@exept.de>
parents: 1289
diff changeset
   760
!DragAndDropManager methodsFor:'accessing-cursor'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   761
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   762
alienCursor:aCursorOrImage
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   763
    "set the cursor used for an alien widget; not an ST/X view
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   764
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   765
    aCursorOrImage isImage ifTrue:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   766
	alienCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   767
    ] ifFalse:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   768
	(aCursorOrImage isMemberOf:Cursor) ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   769
	    alienCursor := aCursorOrImage
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   770
	] ifFalse:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   771
	    "/
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   772
	    "/ use disabled cursor
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   773
	    "/
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   774
	    alienCursor := nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   775
	]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   776
    ]
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   777
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   778
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   779
disabledCursor:aCursorOrImage
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   780
    "set the cursor for an ST/X view, which can not drop the objects
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   781
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   782
    aCursorOrImage isImage ifTrue:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   783
	disabledCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   784
    ] ifFalse:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   785
	(aCursorOrImage isMemberOf:Cursor) ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   786
	    disabledCursor := aCursorOrImage
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   787
	]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   788
    ]
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   791
enabledCursor:aCursorOrImage
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   792
    "set the cursor for an ST/X view, which can drop the objects
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   793
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   794
    aCursorOrImage isImage ifTrue:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   795
	enabledCursor := Cursor fromImage:aCursorOrImage
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   796
    ] ifFalse:[
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   797
	(aCursorOrImage isMemberOf:Cursor) ifTrue:[
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   798
	    enabledCursor := aCursorOrImage
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   799
	]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   800
    ]
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   801
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   802
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   803
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
   804
!DragAndDropManager methodsFor:'dragging-drop source'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   805
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   806
startDragFrom:aView dropSource:aDropSource
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   807
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   808
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   809
    ^ self startDragFrom:aView dropSource:aDropSource offset:#topLeft "/ #center
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   810
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   811
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   812
startDragFrom:aView dropSource:aDropSource offset:anOffset
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   813
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   814
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   815
    dropContext dropSource:aDropSource.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   816
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   817
    ^ self startDrag:(aDropSource dropObjects)
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   818
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   819
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   820
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   821
	     display:(aDropSource displayObjects)
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   822
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   823
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
   824
!DragAndDropManager methodsFor:'dragging-easy startup'!
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   825
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   826
startDrag:draggableObjects from:aView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   827
    "start a drop at the current pointer position
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   828
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   829
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   830
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   831
	      offset:0@0
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   832
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   833
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   834
startDrag:draggableObjects from:aView display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   835
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   836
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   837
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   838
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   839
	      offset:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   840
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   841
	     display:something
874
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
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   844
startDrag:draggableObjects from:aView offset:anOffset
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   845
    "start a drop at the current pointer position with an offset
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   846
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   847
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   848
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   849
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   850
	       atEnd:nil
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   851
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   852
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   853
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   854
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   855
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   856
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   857
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   858
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   859
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   860
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   861
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   862
	       atEnd:aFourArgEndBlock
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   863
	     display:draggableObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   864
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   865
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   866
startDrag:draggableObjects from:aView offset:anOffset atEnd:aFourArgBlock display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   867
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   868
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   869
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   870
     the dropPoint in root-coordinates and the dropPoint within the targetView.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   871
    "
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   872
    |height width fontWdt offset ascent device dispObjs list space|
874
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
    self dropObjects:draggableObjects.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   875
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   876
    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
   877
        ^ self
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   878
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   879
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   880
    device   := aView device.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   881
    space    := 1.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   882
    height   := space negated.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   883
    width    := 0.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   884
    fontWdt  := aView font width.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   885
    ascent   := aView font ascent.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   886
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   887
    (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
   888
        list := self dropObjects
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   889
    ] ifFalse:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   890
        (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
   891
            list := Array with:something
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   892
        ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   893
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   894
    dispObjs := OrderedCollection new.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   895
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   896
    list do:[:el|
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   897
        |obj asc|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   898
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   899
        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
   900
        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
   901
        height := height + space.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   902
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   903
        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
   904
        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
   905
        height := height + (obj heightOn:aView).
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   906
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   907
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   908
    anOffset isSymbol ifTrue:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   909
        offset := (0@0 extent:(width @ height)) perform:anOffset.
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   910
    ] ifFalse:[
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   911
        offset := anOffset ? (0@0).
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   912
    ].
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   913
    offset := offset rounded.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   914
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   915
    dispObjs do:[:el| el at:2 put:((el at:2) - offset) ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   916
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   917
    self startOpaqueDrag:[:p :v| 
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   918
                                |cursor hX hY pDraw|
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   919
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   920
                                cursor := dragView cursor.
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   921
                                hX := cursor hotX.
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   922
                                hY := cursor hotY.
1497
dff682eb74fc avoid jumping icon while moving
Claus Gittinger <cg@exept.de>
parents: 1490
diff changeset
   923
                                pDraw := p "- (hX@hY) + cursor extent".
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   924
                                dispObjs do:[:el| (el at:1) displayOn:v 
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   925
                                                            at:pDraw + (el at:2)
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   926
                                            ] 
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   927
                         ]
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   928
                  offset:offset
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   929
                  extent:width @ height
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   930
                      in:aView
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   931
                      at:nil
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
   932
                   atEnd:aFourArgBlock
881
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   933
981e0791ca36 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 874
diff changeset
   934
    "Modified: / 31.3.1998 / 11:18:04 / cg"
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   935
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   936
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   937
startDrag:draggableObjects from:aView offset:anOffset display:something
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   938
    "start a drop at the current pointer position.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   939
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   940
    ^ self startDrag:draggableObjects
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   941
		from:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   942
	      offset:anOffset
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   943
	       atEnd:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   944
	     display:something
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   945
! !
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   946
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
   947
!DragAndDropManager methodsFor:'dragging-generic'!
342
7563cbf04502 added genericDrag & arrowDrag
Claus Gittinger <cg@exept.de>
parents: 341
diff changeset
   948
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   949
startGenericDrag:aTwoArgDragBlock in:aView at:p atEnd:aFourArgEndBlock
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   950
    "start a generic (caller-provided drag);
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   951
     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
   952
     by inverting again). See startOpaqueDrag for another variant.
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   953
     the dragBlock, aTwoArgDragBlock will be called with two args
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   954
     aPoint and a drawingGC, to perform the drawing at some dragPoint.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   955
     The drag starts in aView at point p.
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   956
     When finished, the endAction is called with four args:
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
   957
     the targetView, the targetViews windowID (useful, if its an alien view),
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   958
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   959
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   960
    ^ self startOpaqueDrag:aTwoArgDragBlock
1166
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   961
		    offset:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   962
		    extent:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   963
			in:aView
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   964
			at:nil
4892defb2ab6 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1162
diff changeset
   965
		     atEnd:aFourArgEndBlock
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   966
!
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   967
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   968
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
   969
    "start an opaque or generic opaque (caller-provided drag);
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   970
     opaque drag means, that the drawing cannot be undone by two inverting
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   971
     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
   972
     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
   973
     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
   974
     drawingGC and the display objects, to perform the drawing at some dragPoint.
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   975
     The drag starts in aView at point p.
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   976
     When finished, the endAction is called with four args:
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   977
     the targetView, the targetViews windowID (useful, if its an alien view),
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   978
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   979
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   980
    |handler numArgs dragBlock dobjs|
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
   981
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   982
    dragOffset := offs ? (Point x:0 y:0).
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   983
    numArgs    := aDragBlock numArgs.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   984
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   985
    numArgs == 3 ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   986
        dobjs := self dropObjects.
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   987
        dragBlock := [:p :v| aDragBlock value:p value:v value:dobjs ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   988
    ] ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   989
        numArgs == 1 ifTrue:[
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   990
            dragBlock := [:p :v| aDragBlock value:p ]
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   991
        ] ifFalse:[
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   992
            dragBlock := aDragBlock
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   993
        ]
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   994
    ].
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
   995
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   996
    anExtent isNil ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   997
        handler := DragHandler startGenericDrag:dragBlock.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
   998
    ] ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
   999
        handler := DragHandler startOpaqueDrag:dragBlock extent:anExtent offset:dragOffset.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1000
    ].
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1001
    self doStart:handler for:aView atEnd:aFourArgEndBlock.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1002
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1003
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1004
1678
9944d3b5d5bf category change
Claus Gittinger <cg@exept.de>
parents: 1661
diff changeset
  1005
!DragAndDropManager methodsFor:'dragging-lines'!
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1006
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1007
startArrowDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1008
    "start a line-drag of an arrow-line.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1009
     The drag starts in aView at point aStartPoint.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1010
     When finished, the endAction is called with four args:
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1011
     the targetView, the targetViews windowID (useful, if its an alien view),
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1012
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1013
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1014
    |p|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1015
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1016
    p := self class translatePointToScreen:aStartPoint from:aView.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1017
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1018
    self doStart:(DragHandler startArrowDragAt:p)
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1019
             for:aView
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1020
           atEnd:aFourArgEndBlock
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1021
!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1022
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1023
startLineDragIn:aView at:aStartPoint atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1024
    "start a line-drag of a normal line.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1025
     The drag starts in aView at point aStartPoint.
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1026
     When finished, the endAction is called with four args:
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1027
     the targetView, the targetViews windowID (useful, if its an alien view),
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1028
     the dropPoint in root-coordinates and the dropPoint within the targetView
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1029
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1030
    |p|
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1031
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1032
    p := self class translatePointToScreen:aStartPoint from:aView.
348
74f1fda9deb0 more args & comments
Claus Gittinger <cg@exept.de>
parents: 346
diff changeset
  1033
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1034
    self doStart:(DragHandler startLineDragAt:p)
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1035
             for:aView
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1036
           atEnd:aFourArgEndBlock
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1037
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1038
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1039
!DragAndDropManager methodsFor:'drawing'!
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1040
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1041
displayObjectFor:anObject on:aDevice
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1042
    "converts an object to a display object
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1043
    "
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1044
    |obj s1 s2|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1045
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1046
    obj := (anObject respondsTo:#displayObject) ifTrue:[anObject displayObject]
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1047
                                               ifFalse:[anObject].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1048
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1049
    obj isString ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1050
        ^ obj
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1051
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1052
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1053
    MessageNotUnderstood 
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1054
        ignoreNotUnderstoodOf:#'onDevice:' 
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1055
        in:[
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1056
            obj := obj onDevice:aDevice
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1057
        ].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1058
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1059
    obj isImage ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1060
        ^ obj clearMaskedPixels
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1061
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1062
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1063
    obj class == LabelAndIcon ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1064
        obj image notNil ifTrue:[obj image clearMaskedPixels].
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1065
        obj icon  notNil ifTrue:[obj icon clearMaskedPixels].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1066
      ^ obj
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1067
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1068
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1069
    (obj class == MultiColListEntry) ifFalse:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1070
        ^ obj
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1071
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1072
    s1 := obj colAt:1.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1073
    s2 := obj colAt:2.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1074
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1075
    s1 isImage ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1076
        s2 isImage  ifTrue:[ ^ self displayObjectFor:(LabelAndIcon form:s1  image:s2) on:aDevice ].
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1077
        s2 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s1 string:s2) on:aDevice ].
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1078
        ^ (s1 on:aDevice) clearMaskedPixels
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1079
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1080
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1081
    s2 isImage ifTrue:[
1572
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1082
        s1 isString ifTrue:[ ^ self displayObjectFor:(LabelAndIcon icon:s2 string:s1) on:aDevice ].
c82e988f5ccd Use #onDevice:
Stefan Vogel <sv@exept.de>
parents: 1553
diff changeset
  1083
        ^ (s2 on:aDevice) clearMaskedPixels
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1084
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1085
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1086
    s1 isString ifTrue:[^ s1].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1087
    s2 isString ifTrue:[^ s2].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1088
  ^ obj
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1089
!
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1090
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1091
showDragging:items in:aView at:p
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1092
    "helper for dragging dragObjects: draw them all"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1093
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1094
    |offs|
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1095
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1096
    offs := 0.
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1097
    items do:[:item |
1490
b2e1f907060c care for cursor when drawing dragObjects (avoid overdrawing the cursor)
Claus Gittinger <cg@exept.de>
parents: 1487
diff changeset
  1098
        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
  1099
        offs := offs + (item heightOn:self)
397
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1100
    ]
7ad4e53d8f49 *** empty log message ***
ca
parents: 394
diff changeset
  1101
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1102
    "Modified: 19.4.1997 / 12:41:24 / cg"
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1103
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1104
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1105
!DragAndDropManager methodsFor:'event catching'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1106
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1107
buttonMotion:button x:x y:y view:aView
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1108
    |device screenPoint oldWg oldId oldPt newId newWg oldTgt newTgt isDroppable cursor|
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1109
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
  1110
    self removePassiveAction.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1111
    escapePressed == true ifTrue:[^ self].
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1112
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1113
    device := dragView device.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1114
    oldWg  := dropContext targetWidget.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1115
    oldId  := dropContext targetId.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1116
    oldPt  := dropContext rootPoint.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1117
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1118
    screenPoint  := self class translatePointToScreen:(x @ y) from:aView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1119
"/    screenPoint := device pointerPosition.
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1120
    dropContext rootPoint:screenPoint.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1121
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1122
    newId := device viewIdFromPoint:screenPoint.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1123
    newWg := device viewFromId:newId.
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1124
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1125
    dropContext rootPoint:screenPoint.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1126
    dropContext targetWidget:newWg id:newId.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1127
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1128
    handler isInterestedInDropTarget ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1129
        "/
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1130
        "/ line or arrow handler
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1131
        "/
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1132
        handler dragTo:screenPoint.
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1133
        ^ self
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1134
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1135
    oldTgt := dropContext dropTarget.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1136
    newTgt := self doFindDropTargetIn:newWg at:screenPoint.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1137
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1138
    newTgt ~= oldTgt ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1139
        "/
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1140
        "/ drop target changed: handler might restore the screen
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1141
        "/
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1142
        handler dropTargetWillChange.
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1143
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1144
        oldTgt notNil ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1145
            "/
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1146
            "/ setup old context
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1147
            "/
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1148
            dropContext targetWidget:oldWg id:oldId.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1149
            oldTgt leave:dropContext.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1150
            dropContext targetWidget:newWg id:newId.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1151
        ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1152
        dropContext dropTarget:newTgt.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1153
        newTgt notNil ifTrue:[ newTgt enter:dropContext ]
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1154
    ] ifFalse:[
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1155
        dropContext dropTarget:newTgt
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1156
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1157
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1158
    "/
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1159
    "/ update the cursor
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1160
    "/
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1161
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1162
    (isDroppable := dropContext canDrop) ifTrue:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1163
        cursor := enabledCursor
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1164
    ] ifFalse:[
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1165
        dropContext isAlienView ifFalse:[cursor := disabledCursor]
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1166
                                 ifTrue:[cursor := alienCursor]
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
    dragView cursor:cursor now:true.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1169
    "/
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1170
    "/ test if droppable state changed
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1171
    "/
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1172
    canDrop == isDroppable ifFalse:[
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1173
        "/
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1174
        "/ droppable state changed: handler might restore the screen
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1175
        "/
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1176
        canDrop := isDroppable.
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1177
        handler dropTargetWillChange
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1178
    ].
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1179
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1180
    newTgt notNil ifTrue:[ newTgt over:dropContext ].
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1181
    handler dragTo:screenPoint.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1182
!
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1183
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1184
buttonRelease:button x:x y:y view:aView
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1185
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1186
    ((button == 1) or:[button == #select]) ifFalse:[
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1187
        ^ self
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1188
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1189
    self removePassiveAction.
1661
3092c6bac88e added passiveAction: invoked if staying over a dropItem for a while
Claus Gittinger <cg@exept.de>
parents: 1638
diff changeset
  1190
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1191
    restoreBlock value.                 "/ restore context before start drag
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1192
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1193
    escapePressed ~~ true ifTrue:[
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1194
        "/
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1195
        "/ at least do the drop operation
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1196
        "/
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1197
        dropAction isNil ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1198
            dropContext doDrop
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1199
        ] ifFalse:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1200
            "/
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1201
            "/ initiator wants to do it himself, manually.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1202
            "/ Thus, no feedBack operation invoked.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1203
            "/
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1204
            dropAction value:(dropContext targetWidget)
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1205
                       value:(dropContext targetId)
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1206
                       value:(dropContext rootPoint)
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1207
                       value:(dropContext targetPoint).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1208
        ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1209
    ].
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1210
!
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1211
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1212
escapePressed
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1213
    "handle key escape
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1214
    "
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1215
    |dropTarget|
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1216
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1217
    escapePressed ~~ true ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1218
        escapePressed := true.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1219
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1220
        handler notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1221
            "/ restore handler
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1222
            dropTarget := dropContext dropTarget.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1223
            handler postDragging.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1224
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1225
            dropTarget notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1226
                "/ invoke leave operation
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1227
                dropTarget  leave:dropContext.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1228
                dropContext dropTarget:nil.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1229
            ].
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1230
        ].
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1231
    ].
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1232
!
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1233
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1234
keyPress:aKey x:x y:y view:aView
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1235
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1236
    escapePressed == true ifTrue:[ ^ self ].    "/ ignorred, escaped was pressed
1629
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1237
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1238
    aKey == #Escape ifTrue:[
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1239
        self escapePressed.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1240
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1241
!
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1242
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1243
processEvent:event
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1244
    |evView|
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1245
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1246
    restoreBlock isNil ifTrue:[^ false].        "/ should not happen
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1247
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1248
    evView := event view.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1249
    evView isNil ifTrue:[^ false].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1250
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1251
    event isInputEvent ifFalse:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1252
        ^ false
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1253
    ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1254
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1255
    event isKeyEvent ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1256
        self keyPress:(event key) x:(event x) y:(event y) view:evView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1257
        ^ true
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1258
    ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1259
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1260
    event isButtonMotionEvent ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1261
        self buttonMotion:(event state) x:(event x) y:(event y) view:evView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1262
    ] ifFalse:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1263
        event isButtonReleaseEvent ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1264
            self buttonRelease:(event button) x:(event x) y:(event y) view:evView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1265
        ]
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1266
    ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1267
    ^ true
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1268
! !
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1269
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1270
!DragAndDropManager methodsFor:'initialization'!
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1271
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1272
initialize
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1273
    super initialize.
394
0539d7b29aa7 *** empty log message ***
ca
parents: 348
diff changeset
  1274
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1275
    dragOffset     := 0 @ 0.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1276
    dropContext    := DropContext new.
1618
70470d120a13 drop context have to know about his manager
penk
parents: 1587
diff changeset
  1277
    dropContext manager:self.
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1278
    alienCursor    := Cursor questionMark.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1279
    enabledCursor  := Cursor thumbsUp.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1280
    disabledCursor := Cursor thumbsDown.
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1281
    canDrop        := false.
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1282
! !
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1283
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1284
!DragAndDropManager methodsFor:'private'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1285
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1286
doDrop:aContext in:aWidget
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1287
    "old drop mechanism
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1288
    "
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1289
    |point|
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1290
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1291
    DragContextQuerySignal answer:aContext do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1292
        DragOriginatorQuerySignal answer:dragView do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1293
            DragOffsetQuerySignal answer:dragOffset do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1294
                aContext targetWidget == aWidget ifTrue:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1295
                    point := aContext targetPoint
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1296
                ] ifFalse:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1297
                    point := 0@0. "/ nil.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1298
                    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1299
                    "/ FeedBack: set the widget which handles the drop
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1300
                    "/
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1301
                    aContext targetWidget:aWidget id:(aWidget id).
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1302
                ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1303
                aWidget drop:(aContext dropObjects) at:point
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1304
            ]
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1305
        ].
609
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1306
    ].
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1307
1072
be90bc383d83 do not pas nil point to dropDestination
Claus Gittinger <cg@exept.de>
parents: 881
diff changeset
  1308
    "Modified: / 11.9.1998 / 00:53:22 / cg"
346
1612c23d9c5d pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1309
!
1612c23d9c5d pass all dropInfo to an end-action
Claus Gittinger <cg@exept.de>
parents: 345
diff changeset
  1310
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1311
doFindDropTargetIn:aView at:aPoint
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1312
    "get the drop target for a view and source at a point or nil
411
8b8b0128d129 *** empty log message ***
ca
parents: 401
diff changeset
  1313
    "
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1314
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1315
    aView isNil ifTrue:[ ^ nil ].
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1316
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1317
    "/
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1318
    "/ new mechanism to get a dropTarget
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1319
    "/
1587
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1320
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1321
    MessageNotUnderstood 
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1322
        ignoreNotUnderstoodOf:#dropTarget
1587
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1323
        in:[ |target|
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1324
            target := aView dropTarget.
1587
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1325
            target notNil ifTrue:[ ^ target ].
1582
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1326
        ].
9e7b1ed9be2e use new notUnderstood catcher
ca
parents: 1572
diff changeset
  1327
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1328
    "/
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1329
    "/ old mechanism to get a dropTarget
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1330
    "/
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1331
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1332
    DragContextQuerySignal answer:dropContext do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1333
        DragOriginatorQuerySignal answer:dragView do:[
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1334
            DragOffsetQuerySignal answer:dragOffset do:[
1587
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1335
                |view dobj|
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1336
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1337
                view := aView.
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1338
                dobj := dropContext dropObjects.
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1339
                [   
9acf4f670187 *** empty log message ***
Stefan Vogel <sv@exept.de>
parents: 1582
diff changeset
  1340
                    (view canDrop:dobj) ifTrue:[
1511
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1341
                        ^ DropTarget receiver:self argument:view dropSelector:#doDrop:in:.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1342
                    ].
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1343
                    (view := view superView) notNil
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1344
                ] whileTrue.
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1345
            ]
99ab0dc04de4 dropContextQuery signal
martin
parents: 1497
diff changeset
  1346
        ].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1347
    ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1348
    ^ nil
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1349
!
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1350
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1351
doStart:aHandler for:aView atEnd:aFourArgEndBlock
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1352
    "setup a handler and a restore block
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1353
    "
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1354
    |device sensor lastActive windowGroup saveContents screenPoint|
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1355
1512
1361c4cdf08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  1356
    device := aView device.
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1357
    lastActive := ActiveDragAndDropManagers at:device ifAbsent:nil.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1358
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1359
    lastActive notNil ifTrue:[
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1360
        "/ self error:'oops - two dnd managers active' mayProceed:true.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1361
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1362
        lastActive forceGiveUp.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1363
        'oops - two dnd managers active' printCR.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1364
    ].
1512
1361c4cdf08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  1365
    ActiveDragAndDropManagers at:device put:self.
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1366
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1367
    dropContext sourceWidget:aView.
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1368
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1369
    dragOffset  isNil ifTrue:[ dragOffset  := 0 @ 0 ].
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1370
    alienCursor isNil ifTrue:[ alienCursor := disabledCursor ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1371
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1372
    dragView      := aView.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1373
    dropAction    := aFourArgEndBlock.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1374
    windowGroup := aView windowGroup.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1375
    handler       := aHandler.
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1376
    escapePressed := false.
609
1343bda17876 pass logical coordinates to dropAction.
Claus Gittinger <cg@exept.de>
parents: 549
diff changeset
  1377
1162
0539b64679ce set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1378
    dropContext dragHandler:aHandler.
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1379
    saveContents := IdentityDictionary new.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1380
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1381
    saveContents at:#preEventHook  put:(windowGroup preEventHook).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1382
    saveContents at:#postEventHook put:(windowGroup postEventHook).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1383
    saveContents at:#cursor        put:(dragView cursor).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1384
    windowGroup preEventHook:self.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1385
    windowGroup postEventHook:self.
1162
0539b64679ce set DragHandler in the DropContext
Claus Gittinger <cg@exept.de>
parents: 1072
diff changeset
  1386
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1387
    restoreBlock := [
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1388
        restoreBlock := nil.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1389
1512
1361c4cdf08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  1390
        ActiveDragAndDropManagers removeKey:device ifAbsent:nil.
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1391
        escapePressed ifFalse:[ aHandler postDragging ].
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1392
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1393
        saveContents notNil ifTrue:[
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1394
            windowGroup  preEventHook:(saveContents at:#preEventHook).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1395
            windowGroup postEventHook:(saveContents at:#postEventHook).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1396
            dragView           cursor:(saveContents at:#cursor).
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1397
            saveContents := nil.
1619
545b8fcc868e *** empty log message ***
ca
parents: 1618
diff changeset
  1398
        ].
874
0730cf44f593 support of Drop -Source -Target and Context
ca
parents: 861
diff changeset
  1399
    ].
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1400
    aHandler preDraggingIn:dragView.
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1401
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1402
    "/ must wait for all pending motion events to arrive, and ignore them
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1403
    (sensor := dragView sensor) notNil ifTrue:[
1512
1361c4cdf08e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1511
diff changeset
  1404
        device sync.        
1289
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1405
        sensor flushMotionEventsFor:nil.
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1406
    ].
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1407
0f7688ddff2c grabbing changes to restore grab,
ca
parents: 1166
diff changeset
  1408
    "/ start with a first draw at the current mouse position
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1409
    screenPoint := device pointerPosition.
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1410
    self buttonMotion:1 x:(screenPoint x) y:(screenPoint y) view:(device rootView).
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1411
!
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1412
1685
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1413
forceGiveUp
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1414
    "called if the DragAndDropManager no longer should be
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1415
     active; a second one is started
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1416
    "
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1417
    self escapePressed.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1418
    self removePassiveAction.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1419
    restoreBlock value.
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1420
!
82350f572e2f work araound if a second DragAndDropManager is started
ca
parents: 1678
diff changeset
  1421
1487
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1422
saveDraw:aBlock
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1423
    handler postDragging.
6cefff982779 *** empty log message ***
martin
parents: 1484
diff changeset
  1424
    aBlock value.
1638
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1425
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1426
    escapePressed == true ifFalse:[
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1427
        "/ reread and show drag items
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1428
        handler rereadSaveArea.
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1429
        handler restoreFromSaveArea.
67a340f6249f *** empty log message ***
ca
parents: 1629
diff changeset
  1430
    ].
548
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1431
! !
1a81d6be65b4 added comments & docu, examples.
Claus Gittinger <cg@exept.de>
parents: 515
diff changeset
  1432
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1433
!DragAndDropManager class methodsFor:'documentation'!
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1434
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1435
version
1686
fe4a13681941 add eventHooks on windowGroup
ca
parents: 1685
diff changeset
  1436
    ^ '$Header: /cvs/stx/stx/libview2/DragAndDropManager.st,v 1.47 2003-01-21 07:23:12 ca Exp $'
341
5afe98e6185b intitial checkin
Claus Gittinger <cg@exept.de>
parents:
diff changeset
  1437
! !
1629
9b0f45e63e24 bug fix if operation cancled by #Escape, must invoke #leave
ca
parents: 1619
diff changeset
  1438
628
22085aaf983c DragOriginatorQuerySignal added
ca
parents: 609
diff changeset
  1439
DragAndDropManager initialize!