DropTarget.st
changeset 2091 0fdd1265fd82
parent 1822 ceeb17948f5d
child 2251 7e4757269c0c
equal deleted inserted replaced
2090:025a61199960 2091:0fdd1265fd82
    41 documentation
    41 documentation
    42 "
    42 "
    43     this class keeps the current target of the drop operation; the object respoonsible
    43     this class keeps the current target of the drop operation; the object respoonsible
    44     for the widget under the current mouse position.
    44     for the widget under the current mouse position.
    45 
    45 
    46     receiver        <Object>        receiver to which the requests are sent. the
    46     receiver        <Object>        receiver to which the requests are sent. 
    47                                     widget or an application.
    47                                     The widget or an application.
    48 
    48 
    49     argument        <Object>        user defined argument
    49     argument        <Object>        user defined argument
    50 
    50 
    51     enterSelector   <Symbol>        send the first time to the drop target when entering
    51     enterSelector   <Symbol>        send the first time to the drop target when entering
    52                                     the widget.
    52                                     the widget.
    69         DropContext
    69         DropContext
    70 
    70 
    71     [author:]
    71     [author:]
    72         Claus Atzkern
    72         Claus Atzkern
    73 "
    73 "
    74 
       
    75 ! !
    74 ! !
    76 
    75 
    77 !DropTarget class methodsFor:'instance creation'!
    76 !DropTarget class methodsFor:'instance creation'!
    78 
    77 
    79 receiver:aReceiver
    78 receiver:aReceiver
   121 canDropSelector
   120 canDropSelector
   122     "selector called to get a feedback if context is droppable.
   121     "selector called to get a feedback if context is droppable.
   123      the arguments to the selector are:
   122      the arguments to the selector are:
   124         0       nothing
   123         0       nothing
   125         1       aDropContext
   124         1       aDropContext
   126         2       aDropContext and the argument
   125         2       aDropContext and the argument"
   127     "
   126     
   128     ^ canDropSelector
   127     ^ canDropSelector
   129 !
   128 !
   130 
   129 
   131 canDropSelector:something
   130 canDropSelector:something 
   132     "selector called to get a feedback if context is droppable.
   131     "selector called to get a feedback if context is droppable.
   133      the arguments to the selector are:
   132      the arguments to the selector are:
   134         0       nothing
   133         0       nothing
   135         1       aDropContext
   134         1       aDropContext
   136         2       aDropContext and the argument
   135         2       aDropContext and the argument"
   137     "
   136     
   138     canDropSelector := something.
   137     canDropSelector := something.
   139 !
   138 !
   140 
   139 
   141 dropSelector
   140 dropSelector
   142     "return the selector of the message which is sent to the drop target 
   141     "return the selector of the message which is sent to the drop target 
   221 
   220 
   222      Depending on the number of arguments of the selector,
   221      Depending on the number of arguments of the selector,
   223      the arguments of the message are:
   222      the arguments of the message are:
   224         0       nothing
   223         0       nothing
   225         1       aDropContext
   224         1       aDropContext
   226         2       aDropContext and the argument
   225         2       aDropContext and the argument"
   227     "
   226     
   228     ^ overSelector
   227     ^ overSelector
   229 !
   228 !
   230 
   229 
   231 overSelector:something
   230 overSelector:something
   232     "specify the selector of the message which is sent to the drop target 
   231     "specify the selector of the message which is sent to the drop target 
   255 ! !
   254 ! !
   256 
   255 
   257 !DropTarget methodsFor:'actions'!
   256 !DropTarget methodsFor:'actions'!
   258 
   257 
   259 drop:aContext
   258 drop:aContext
   260     "sent when the mouse button is released within the current widget."
   259     "sent, when the mouse button is released within the current widget."
   261 
   260 
   262     self perform:dropSelector withContext:aContext
   261     self receiverPerform:dropSelector withContext:aContext
   263 !
   262 !
   264 
   263 
   265 enter:aContext
   264 enter:aContext
   266     "sent when entering the widget for the first time."
   265     "sent, when entering a widget."
   267 
   266 
   268     self perform:enterSelector withContext:aContext
   267     self receiverPerform:enterSelector withContext:aContext
   269 !
   268 !
   270 
   269 
   271 leave:aContext
   270 leave:aContext
   272     "sent the last time, when leaving the widget."
   271     "sent, when leaving a widget."
   273 
   272 
   274     self perform:leaveSelector withContext:aContext
   273     self receiverPerform:leaveSelector withContext:aContext
   275 !
   274 !
   276 
   275 
   277 over:aContext
   276 over:aContext
   278     "sent whenever the mouse is moved over the widget."
   277     "sent, whenever the mouse is moved over the widget."
   279 
   278 
   280     self perform:overSelector withContext:aContext
   279     self receiverPerform:overSelector withContext:aContext
   281 ! !
   280 ! !
   282 
   281 
   283 !DropTarget methodsFor:'instance creation'!
   282 !DropTarget methodsFor:'instance creation'!
   284 
   283 
   285 receiver:aReceiver argument:anArgument
   284 receiver:aReceiver argument:anArgument
   298     canDropSelector := s2.
   297     canDropSelector := s2.
   299 ! !
   298 ! !
   300 
   299 
   301 !DropTarget methodsFor:'private'!
   300 !DropTarget methodsFor:'private'!
   302 
   301 
   303 perform:aSelector withContext:aContext
   302 receiverPerform:aSelector withContext:aContext
   304     "perform the selector"
   303     "let the receiver perform the selector"
   305 
   304 
   306     aSelector notNil ifTrue:[
   305     aSelector notNil ifTrue:[
   307         ^ receiver perform:aSelector withOptionalArgument:aContext and:argument
   306         ^ receiver perform:aSelector withOptionalArgument:aContext and:argument
   308     ]
   307     ]
   309 ! !
   308 ! !
   312 
   311 
   313 canDrop:aContext
   312 canDrop:aContext
   314     "send to the receiver to ask if the context is droppable"
   313     "send to the receiver to ask if the context is droppable"
   315 
   314 
   316     canDropSelector notNil ifTrue:[
   315     canDropSelector notNil ifTrue:[
   317         ^ receiver perform:canDropSelector withOptionalArgument:aContext and:argument
   316         ^ self receiverPerform:canDropSelector withContext:aContext
   318     ].
   317     ].
   319     ^ true
   318     ^ true
   320 ! !
   319 ! !
   321 
   320 
   322 !DropTarget class methodsFor:'documentation'!
   321 !DropTarget class methodsFor:'documentation'!
   323 
   322 
   324 version
   323 version
   325     ^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.3 2003-10-06 15:29:36 cg Exp $'
   324     ^ '$Header: /cvs/stx/stx/libview2/DropTarget.st,v 1.4 2006-01-24 16:53:42 cg Exp $'
   326 ! !
   325 ! !