Hi Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop? Here is what method doc says: "Return the current reference position of the receiver" Thanks, Alex |
The center of the morph usually? Or sometime another point of importance for that morph (the tip of an arrow)?
Reference point for rotating the morph :) In drag and drop, allow one to set the position of the dropped morph into the coordinates of the dropped into morph. Probably needed because of the transform morphs... Thierry 2016-01-27 16:11 GMT+01:00 Aliaksei Syrel <[hidden email]>:
|
In reply to this post by Aliaksei Syrel
#referencePostion returns the specified center for the morph in global coordinates.
By default this will be the same as “self bounds origin + (self bounds extent/2.0)” but can have other depending on what #rotationCenter
returns. #referencePositon: on the other hand do not set a new centre, but moves the morph to a new position by using the referencePosition
as origin instead of its top left corner. Example:
| m | m := Morph new
color: Color orange; extent: 200@72; openCenteredInWorld; yourself.
m on: #click send: #value to: [ m referencePosition: (m referencePosition + (10@10)) ] . Looking at Morph>>#handleDropMorph: referencePosition is used to place the dropped morph in centre of the new owner.
“ observation:
‘(self transformedFrom: anEvent hand world) globalPointToLocal: aMorph referencePosition’ looks incomplete as it will always be equal
to just doing ‘aMorph referencePosition’ because #transformedFrom: always returns an IdentityTransform where # globalPointToLocal: just returns the point given to it. “ Best regards, Henrik From: Pharo-dev [mailto:[hidden email]]
On Behalf Of Aliaksei Syrel Hi Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop? Here is what method doc says: "Return the current reference position of the receiver" Thanks, Alex |
From: Pharo-dev [mailto:[hidden email]]
On Behalf Of Henrik Nergaard #referencePostion returns the specified center for the morph in global coordinates.
By default this will be the same as “self bounds origin + (self bounds extent/2.0)” but can have other depending on what #rotationCenter
returns. #referencePositon: on the other hand do not set a new centre, but moves the morph to a new position by using the referencePosition
as origin instead of its top left corner. Example:
| m | m := Morph new
color: Color orange; extent: 200@72; openCenteredInWorld; yourself.
m on: #click send: #value to: [ m referencePosition: (m referencePosition + (10@10)) ] . Looking at Morph>>#handleDropMorph: referencePosition
is used to place the dropped morph in centre of the new owner. “ observation:
‘(self transformedFrom: anEvent hand world) globalPointToLocal:
aMorph referencePosition’ looks incomplete as it will always be equal to just doing ‘aMorph referencePosition’ because #transformedFrom: always returns an IdentityTransform where # globalPointToLocal: just returns the point given to it. “ Correction: #transformedFrom: translates the dropped morph “center” to the receiving morph local coordinates (local from the owning transformationMorph)
if it has an owner which is a transformation type Morph (see implementors #tranformFrom:) .
Best regards, Henrik From: Pharo-dev [[hidden email]]
On Behalf Of Aliaksei Syrel Hi Do anyone know what is Morph>>#referencePosition and why is it used to handle drag and drop? Here is what method doc says: "Return the current reference position of the receiver" Thanks, Alex |
Aha, understood! Thanks a lot :) Cheers, Alex On Wed, Jan 27, 2016 at 5:04 PM, Henrik Nergaard <[hidden email]> wrote:
|
Free forum by Nabble | Edit this page |