From 4fdf0be9fec3ace5a1789a155d4f7a331bb089ce Mon Sep 17 00:00:00 2001 From: "Christophe.Boulain" <> Date: Fri, 2 Oct 2009 13:02:23 +0000 Subject: Enhancement on drag & drop controls. --- framework/Web/UI/ActiveControls/TDropContainer.php | 86 +++++++++++++++------- 1 file changed, 58 insertions(+), 28 deletions(-) (limited to 'framework/Web/UI/ActiveControls/TDropContainer.php') diff --git a/framework/Web/UI/ActiveControls/TDropContainer.php b/framework/Web/UI/ActiveControls/TDropContainer.php index 75a80625..8f7792f3 100755 --- a/framework/Web/UI/ActiveControls/TDropContainer.php +++ b/framework/Web/UI/ActiveControls/TDropContainer.php @@ -30,7 +30,9 @@ Prado::using('System.Web.UI.ActiveControls.TActivePanel'); * * Events: * - * {@link OnDrop OnDrop} : raised when a TDraggable control is dropped. The dropped control is encapsulated in the event parameter + * {@link OnDrop OnDrop} : raised when a TDraggable control is dropped. The dropped control id is encapsulated in the event parameter, + * as well as mouse coordinates and key modifiers status + * * * @author Christophe BOULAIN (Christophe.Boulain@gmail.com) * @copyright Copyright © 2008, PradoSoft @@ -115,17 +117,13 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan /** * Raises the onDrop event. - * The dropped control is encapsulated into a {@link TDropContainerEventParameter} + * The dropp parameters are encapsulated into a {@link TDropContainerEventParameter} * - * @param string $dropControlId + * @param object $dropControlId */ - public function onDrop ($dropControlId) + public function onDrop ($dropParams) { - // Find the control - // Warning, this will not work if you have a '_' in your control Id ! - $dropControlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$dropControlId); - $control=$this->getPage()->findControl($dropControlId); - $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($control)); + $this->raiseEvent('OnDrop', $this, new TDropContainerEventParameter ($dropParams)); } @@ -244,28 +242,60 @@ class TDropContainer extends TPanel implements IActiveControl, ICallbackEventHan */ class TDropContainerEventParameter extends TEventParameter { - /* - * the id of control which has been dropped - * @var string - */ - private $_droppedControl; - - /** - * constructor - * - * @param string the id of control which been dropped - */ - public function __construct ($control) + private $_dragElementId; + private $_screenX; + private $_screenY; + private $_offsetX; + private $_offsetY; + private $_clientX; + private $_clientY; + private $_shiftKey; + private $_ctrlKey; + private $_altKey; + + public function __construct($dropParams) { - $this->_droppedControl=$control; + $this->_dragElementId = $dropParams->DragElementID; + $this->_screenX = $dropParams->ScreenX; + $this->_screenY = $dropParams->ScreenY; + $this->_offsetX = isset($dropParams->OffsetX) ? $dropParams->OffsetX : false; + $this->_offsetY = isset($dropParams->OffsetY) ? $dropParams->OffsetY : false; + $this->_clientX = $dropParams->ClientX; + $this->_clientY = $dropParams->ClientY; + $this->_shiftKey = TPropertyValue::ensureBoolean($dropParams->ShiftKey); + $this->_ctrlKey = TPropertyValue::ensureBoolean($dropParams->CtrlKey); + $this->_altKey = TPropertyValue::ensureBoolean($dropParams->AltKey); } - + + public function getDragElementId() { return $this->_dragElementId; } + public function getScreenX() { return $this->_screenX; } + public function getScreenY() { return $this->_screenY; } + public function getOffsetX() { return $this->_offsetX; } + public function geOffsetY() { return $this->_offsetY; } + public function getClientX() { return $this->_clientX; } + public function getClientY() { return $this->_clientY; } + public function getShiftKey() { return $this->_shiftKey; } + public function getCtrlKey() { return $this->_ctrlKey; } + public function getAltKey() { return $this->_altKey; } + /** - * @return TDraggable + * GetDroppedControl + * + * Compatibility method to get the dropped control + * @return TControl dropped control, or null if not found */ - public function getDroppedControl () - { - return $this->_droppedControl; - } + public function getDroppedControl () + { + $control=null; + $service=prado::getApplication()->getService(); + if ($service instanceof TPageService) + { + // Find the control + // Warning, this will not work if you have a '_' in your control Id ! + $dropControlId=str_replace(TControl::CLIENT_ID_SEPARATOR,TControl::ID_SEPARATOR,$this->_dragElementId); + $control=$service->getRequestedPage()->findControl($dropControlId); + } + return $control; + } } ?> \ No newline at end of file -- cgit v1.2.3