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