Does anybody have an idea how to drag a (rectangular) shape over the
whole screen? I'm using this for a drag & drop feature to indicate the object's size and exact drop location. My current implementation goes like this: Screen default displayShape: shape at: InputState default mousePoint - offset forMilliseconds: 100. whereby the shape is initialized with aPointArray. This however creates really annoying flicker. How can a shape be dragged smoothly? Any suggestion is appreciated. Andre |
Sorry for the noise. I just discovered one possible solution myself (see
code below). MyDragDropManager is a subclass of DragDropManager extended by an instance variable bearing the dragged shape. After the drop, the flag "dragging" is reset to false: MyDragDropManager>>dragStartAt: aPoint dragging ifTrue:[ ^nil ]. dragging := true. [ [ dragging ] whileTrue:[ Processor yield. dropSource showDragShape. ]. ] forkAt: Processor userBackgroundPriority - 1. MyDropSource>>showDragShape (shape notNil and:[ offset notNil ]) ifTrue:[ Screen default displayShape: shape at: InputState default mousePoint - offset forMilliseconds: 20. ]. In the previous version, I included a delay in the inner loop of the background process, because other processes were disturbed by drag &drop actions. I didn't realize that I simply needed to reduce the process priority. Removing the delay and lowering the process priority also removed the flicker ;-) Although the shape is only visible for 20ms, the human eye is too slow to recognize that. The overall impression is a smooth move. Andre Andre Schnoor wrote: > Does anybody have an idea how to drag a (rectangular) shape over the > whole screen? I'm using this for a drag & drop feature to indicate the > object's size and exact drop location. > > My current implementation goes like this: > > Screen default > displayShape: shape > at: InputState default mousePoint - offset > forMilliseconds: 100. > whereby the shape is initialized with aPointArray. This however > creates really annoying flicker. How can a shape be dragged smoothly? > > Any suggestion is appreciated. > > Andre > > > |
Andre,
are you aware of the library methods for this on the class Screen? Their selectors all start with #drag... R - On Jan 20, 2007, at 9:59 AM, Andre Schnoor wrote: > Sorry for the noise. I just discovered one possible solution myself > (see code below). > > MyDragDropManager is a subclass of DragDropManager extended by an > instance variable bearing the dragged shape. After the drop, the > flag "dragging" is reset to false: > > > MyDragDropManager>>dragStartAt: aPoint > dragging ifTrue:[ ^nil ]. > dragging := true. > [ > [ dragging ] whileTrue:[ > Processor yield. > dropSource showDragShape. > ]. > ] forkAt: Processor userBackgroundPriority - 1. > > MyDropSource>>showDragShape > (shape notNil and:[ offset notNil ]) ifTrue:[ > Screen default > displayShape: shape > at: InputState default mousePoint - offset > forMilliseconds: 20. ]. > > In the previous version, I included a delay in the inner loop of > the background process, because other processes were disturbed by > drag &drop actions. I didn't realize that I simply needed to reduce > the process priority. Removing the delay and lowering the process > priority also removed the flicker ;-) > > Although the shape is only visible for 20ms, the human eye is too > slow to recognize that. The overall impression is a smooth move. > > Andre > > > Andre Schnoor wrote: >> Does anybody have an idea how to drag a (rectangular) shape over >> the whole screen? I'm using this for a drag & drop feature to >> indicate the object's size and exact drop location. >> >> My current implementation goes like this: >> >> Screen default >> displayShape: shape >> at: InputState default mousePoint - offset >> forMilliseconds: 100. whereby the shape is initialized >> with aPointArray. This however creates really annoying flicker. >> How can a shape be dragged smoothly? >> >> Any suggestion is appreciated. >> >> Andre >> >> >> > > |
AFAIK the library methods are blocking. Dragging a shape across the
screen alone doesn't make much sense. There's no cursor feedback, no highlighting of active drop targets etc (let alone other real-time tasks running in the background. Andre Reinout Heeck wrote: > Andre, > > are you aware of the library methods for this on the class Screen? > Their selectors all start with #drag... > > > R > - > > > > > On Jan 20, 2007, at 9:59 AM, Andre Schnoor wrote: > >> Sorry for the noise. I just discovered one possible solution myself >> (see code below). >> >> MyDragDropManager is a subclass of DragDropManager extended by an >> instance variable bearing the dragged shape. After the drop, the flag >> "dragging" is reset to false: >> >> >> MyDragDropManager>>dragStartAt: aPoint >> dragging ifTrue:[ ^nil ]. >> dragging := true. >> [ >> [ dragging ] whileTrue:[ >> Processor yield. >> dropSource showDragShape. >> ]. >> ] forkAt: Processor userBackgroundPriority - 1. >> >> MyDropSource>>showDragShape >> (shape notNil and:[ offset notNil ]) ifTrue:[ >> Screen default >> displayShape: shape >> at: InputState default mousePoint - offset >> forMilliseconds: 20. ]. >> >> In the previous version, I included a delay in the inner loop of the >> background process, because other processes were disturbed by drag >> &drop actions. I didn't realize that I simply needed to reduce the >> process priority. Removing the delay and lowering the process >> priority also removed the flicker ;-) >> >> Although the shape is only visible for 20ms, the human eye is too >> slow to recognize that. The overall impression is a smooth move. >> >> Andre >> >> >> Andre Schnoor wrote: >>> Does anybody have an idea how to drag a (rectangular) shape over the >>> whole screen? I'm using this for a drag & drop feature to indicate >>> the object's size and exact drop location. >>> >>> My current implementation goes like this: >>> >>> Screen default >>> displayShape: shape >>> at: InputState default mousePoint - offset >>> forMilliseconds: 100. whereby the shape is initialized >>> with aPointArray. This however creates really annoying flicker. How >>> can a shape be dragged smoothly? >>> >>> Any suggestion is appreciated. >>> >>> Andre >>> >>> >>> >> >> > > |
Free forum by Nabble | Edit this page |