You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@royale.apache.org by yi...@apache.org on 2022/02/22 08:51:14 UTC
[royale-asjs] branch develop updated: Emulation - make sure ADG knows not to expand/collapse unless disclosure icon is clicked
This is an automated email from the ASF dual-hosted git repository.
yishayw pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/royale-asjs.git
The following commit(s) were added to refs/heads/develop by this push:
new 211d770 Emulation - make sure ADG knows not to expand/collapse unless disclosure icon is clicked
new bacc700 Merge branch 'develop' of https://github.com/apache/royale-asjs into develop
211d770 is described below
commit 211d770eecc77bad2c4badf1f0e7284e4af78bdc
Author: Yishay Weiss <yi...@hotmail.com>
AuthorDate: Tue Feb 22 10:49:57 2022 +0200
Emulation - make sure ADG knows not to expand/collapse unless disclosure icon is clicked
---
.../AdvancedDataGridItemRenderer.as | 17 ++++++++-
...vancedDataGridSingleSelectionMouseController.as | 42 +++++++++++-----------
.../src/main/royale/mx/supportClasses/IFoldable.as | 26 ++++++++++++++
3 files changed, 64 insertions(+), 21 deletions(-)
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridItemRenderer.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridItemRenderer.as
index 5f96090..30b717f 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridItemRenderer.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridItemRenderer.as
@@ -57,6 +57,7 @@ import org.apache.royale.core.IUIBase;
import org.apache.royale.geom.Point;
import org.apache.royale.utils.getSelectionRenderBead;
import org.apache.royale.utils.PointUtils;
+import mx.supportClasses.IFoldable;
//--------------------------------------
// Events
@@ -96,7 +97,7 @@ import org.apache.royale.utils.PointUtils;
* @productversion Royale 0.9.3
*/
public class AdvancedDataGridItemRenderer extends StringItemRenderer
- implements IDataRenderer,IDropInListItemRenderer,IListDataItemRenderer,IListItemRenderer
+ implements IDataRenderer,IDropInListItemRenderer,IListDataItemRenderer,IListItemRenderer,IFoldable
{
/* extends UITextField
implements IDataRenderer,
@@ -175,6 +176,8 @@ public class AdvancedDataGridItemRenderer extends StringItemRenderer
}
indent += (treeListData.hasChildren ? (treeListData.open ? "▼" : "▶") : "") + extraSpace;
+ _canFold = treeListData.hasChildren && treeListData.open;
+ _canUnfold = treeListData.hasChildren && !treeListData.open;
}
if (column.labelFunction)
@@ -209,6 +212,18 @@ public class AdvancedDataGridItemRenderer extends StringItemRenderer
{
_listData = value;
}
+
+ private var _canFold:Boolean;
+ public function get canFold():Boolean
+ {
+ return _canFold;
+ }
+
+ private var _canUnfold:Boolean;
+ public function get canUnfold():Boolean
+ {
+ return _canUnfold;
+ }
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridSingleSelectionMouseController.as b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridSingleSelectionMouseController.as
index fc3ed63..91161e2 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridSingleSelectionMouseController.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/advancedDataGridClasses/AdvancedDataGridSingleSelectionMouseController.as
@@ -29,6 +29,7 @@ package mx.controls.advancedDataGridClasses
import org.apache.royale.events.IEventDispatcher;
import org.apache.royale.events.ItemClickedEvent;
import org.apache.royale.html.beads.controllers.ListSingleSelectionMouseController;
+ import mx.supportClasses.IFoldable;
/**
* The TreeSingleSelectionMouseController class is a controller for
@@ -74,30 +75,31 @@ package mx.controls.advancedDataGridClasses
{
var node:Object = event.data;
- var adg:AdvancedDataGrid = (_strand as AdvancedDataGridColumnList).grid as AdvancedDataGrid;
- var hasChildren:Boolean = adg.hasChildren(node);
- if (hasChildren)
- {
- if (adg.isItemOpen(node)) {
- adg.closeNode(node);
- } else {
- adg.openNode(node);
- }
- }
+ var adg:AdvancedDataGrid = (_strand as AdvancedDataGridColumnList).grid as AdvancedDataGrid;
+ var hasChildren:Boolean = adg.hasChildren(node);
+ var foldableTarget:IFoldable = event.target as IFoldable;
+ if (hasChildren && (foldableTarget is IFoldable))
+ {
+ if (adg.isItemOpen(node) && foldableTarget.canFold) {
+ adg.closeNode(node);
+ } else if (foldableTarget.canUnfold) {
+ adg.openNode(node);
+ }
+ }
//avoid doing this (it breaks ctrl-click de-selection which is managed at the top level):
//was: reset the selection
// ((_strand as AdvancedDataGridColumnList).model as ISelectionModel).selectedItem = node;
- IEventDispatcher(_strand).dispatchEvent(new Event("change"));
-
- var newEvent:ListEvent = new ListEvent(ListEvent.ITEM_CLICK);
- newEvent.rowIndex = event.index;
- var lists:Array = (adg.view as AdvancedDataGridView).columnLists;
- for (var i:int = 0; i < lists.length; i++)
- if (lists[i] == _strand) break;
- newEvent.columnIndex = i;
- newEvent.itemRenderer = event.currentTarget;
- IEventDispatcher(_strand).dispatchEvent(newEvent);
+ IEventDispatcher(_strand).dispatchEvent(new Event("change"));
+
+ var newEvent:ListEvent = new ListEvent(ListEvent.ITEM_CLICK);
+ newEvent.rowIndex = event.index;
+ var lists:Array = (adg.view as AdvancedDataGridView).columnLists;
+ for (var i:int = 0; i < lists.length; i++)
+ if (lists[i] == _strand) break;
+ newEvent.columnIndex = i;
+ newEvent.itemRenderer = event.currentTarget;
+ IEventDispatcher(_strand).dispatchEvent(newEvent);
}
}
}
diff --git a/frameworks/projects/MXRoyale/src/main/royale/mx/supportClasses/IFoldable.as b/frameworks/projects/MXRoyale/src/main/royale/mx/supportClasses/IFoldable.as
new file mode 100644
index 0000000..71105d6
--- /dev/null
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/supportClasses/IFoldable.as
@@ -0,0 +1,26 @@
+////////////////////////////////////////////////////////////////////////////////
+//
+// Licensed to the Apache Software Foundation (ASF) under one or more
+// contributor license agreements. See the NOTICE file distributed with
+// this work for additional information regarding copyright ownership.
+// The ASF licenses this file to You under the Apache License, Version 2.0
+// (the "License"); you may not use this file except in compliance with
+// the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+//
+////////////////////////////////////////////////////////////////////////////////
+package mx.supportClasses
+{
+ public interface IFoldable
+ {
+ function get canFold():Boolean;
+ function get canUnfold():Boolean;
+ }
+}
\ No newline at end of file