This is an automated email from the ASF dual-hosted git repository. carlosrovira 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 9843627 jewel-virtuallist and virtualcombobox: avoid RTE due to new keyboard capabilities. implement for now the placeholder to avoid RTE, but still not implemented real functionality new a629de4 Merge branch 'develop' of https://gitbox.apache.org/repos/asf/royale-asjs into develop 9843627 is described below commit 98436273ef3d43fdf1522e83a1b107195a4446d7 Author: Carlos Rovira <carlosrov...@apache.org> AuthorDate: Wed Apr 29 19:16:31 2020 +0200 jewel-virtuallist and virtualcombobox: avoid RTE due to new keyboard capabilities. implement for now the placeholder to avoid RTE, but still not implemented real functionality --- .../projects/Jewel/src/main/resources/defaults.css | 1 + .../projects/Jewel/src/main/royale/JewelClasses.as | 1 + .../controllers/VirtualListKeyDownController.as | 156 +++++++++++++++++++++ .../royale/jewel/beads/views/VirtualListView.as | 62 +++++++- .../Jewel/src/main/sass/components/_list.sass | 3 +- 5 files changed, 221 insertions(+), 2 deletions(-) diff --git a/frameworks/projects/Jewel/src/main/resources/defaults.css b/frameworks/projects/Jewel/src/main/resources/defaults.css index bfa5856..113d46e 100644 --- a/frameworks/projects/Jewel/src/main/resources/defaults.css +++ b/frameworks/projects/Jewel/src/main/resources/defaults.css @@ -3268,6 +3268,7 @@ j|VirtualList { IBeadView: ClassReference("org.apache.royale.jewel.beads.views.VirtualListView"); IBeadLayout: ClassReference("org.apache.royale.jewel.beads.layouts.VirtualListVerticalLayout"); IDataProviderItemRendererMapper: ClassReference("org.apache.royale.jewel.beads.itemRenderers.VirtualDataItemRendererFactoryForCollectionView"); + IBeadKeyController: ClassReference("org.apache.royale.jewel.beads.controllers.VirtualListKeyDownController"); } j|Navigation { diff --git a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as index 29c6ef5..069f7dd 100644 --- a/frameworks/projects/Jewel/src/main/royale/JewelClasses.as +++ b/frameworks/projects/Jewel/src/main/royale/JewelClasses.as @@ -53,6 +53,7 @@ package import org.apache.royale.jewel.beads.controllers.AlertController; AlertController; import org.apache.royale.jewel.beads.controllers.ListSingleSelectionMouseController; ListSingleSelectionMouseController; import org.apache.royale.jewel.beads.controllers.ListKeyDownController; ListKeyDownController; + import org.apache.royale.jewel.beads.controllers.VirtualListKeyDownController; VirtualListKeyDownController; import org.apache.royale.jewel.beads.controllers.TableCellSelectionMouseController; TableCellSelectionMouseController; import org.apache.royale.jewel.beads.controllers.ComboBoxController; ComboBoxController; import org.apache.royale.jewel.beads.controllers.SnackbarController; SnackbarController; diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/VirtualListKeyDownController.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/VirtualListKeyDownController.as new file mode 100644 index 0000000..9ea923a --- /dev/null +++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/controllers/VirtualListKeyDownController.as @@ -0,0 +1,156 @@ +//////////////////////////////////////////////////////////////////////////////// +// +// 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 org.apache.royale.jewel.beads.controllers +{ + import org.apache.royale.core.Bead; + import org.apache.royale.core.IBeadKeyController; + import org.apache.royale.core.IFocusable; + import org.apache.royale.core.IRemovableBead; + import org.apache.royale.core.ISelectionModel; + import org.apache.royale.core.IStrand; + import org.apache.royale.events.IEventDispatcher; + import org.apache.royale.events.KeyboardEvent; + import org.apache.royale.html.beads.IListView; + import org.apache.royale.jewel.beads.views.IScrollToIndexView; + import org.apache.royale.utils.sendEvent; + + /** + * The Jewel ListSingleSelectionMouseController class is a controller for + * org.apache.royale.jewel.List. + * + * Controllers watch for events from the interactive portions of a View and + * update the data model or dispatch a semantic event. + * This controller watches for events from the item renderers + * and updates an ISelectionModel (which only supports single + * selection). Other controller/model pairs would support + * various kinds of multiple selection. + * + * Jewel controller takes into account if the component + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.7 + */ + public class VirtualListKeyDownController extends Bead implements IBeadKeyController, IRemovableBead + { + /** + * Constructor. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.7 + */ + public function VirtualListKeyDownController() + { + } + + /** + * The model. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.7 + */ + protected var listModel:ISelectionModel; + + /** + * The view. + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.7 + */ + protected var listView:IListView; + + /** + * @copy org.apache.royale.core.IBead#strand + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.7 + * @royaleignorecoercion org.apache.royale.core.ISelectionModel + * @royaleignorecoercion org.apache.royale.jewel.beads.models.IJewelSelectionModel + * @royaleignorecoercion org.apache.royale.events.IEventDispatcher + * @royaleignorecoercion org.apache.royale.core.IListView + */ + override public function set strand(value:IStrand):void + { + _strand = value; + listModel = value.getBeadByType(ISelectionModel) as ISelectionModel; + listView = value.getBeadByType(IListView) as IListView; + + listenOnStrand(KeyboardEvent.KEY_DOWN, keyDownEventHandler); + } + + /** + * The actions needed before the removal + * + * @langversion 3.0 + * @playerversion Flash 10.2 + * @playerversion AIR 2.6 + * @productversion Royale 0.9.8 + */ + public function tearDown():void + { + IEventDispatcher(_strand).removeEventListener(KeyboardEvent.KEY_DOWN, keyDownEventHandler); + } + + /** + * @private + */ + protected function keyDownEventHandler(event:KeyboardEvent):void + { + // avoid Tab loose the normal behaviour, for navigation we don't want build int scrolling support in browsers + if(event.key === KeyboardEvent.KEYCODE__TAB) + return; + + event.preventDefault(); + + // var index:int = listModel.selectedIndex; + + // if(event.key === KeyboardEvent.KEYCODE__UP || event.key === KeyboardEvent.KEYCODE__LEFT) + // { + // if(index > 0) + // listModel.selectedIndex--; + // } + // else if(event.key === KeyboardEvent.KEYCODE__DOWN || event.key === KeyboardEvent.KEYCODE__RIGHT) + // { + // listModel.selectedIndex++; + // } + + // TODO + // if(index != listModel.selectedIndex) + // { + // listModel.selectedItem = listModel.dataProvider.getItemAt(listModel.selectedIndex); + + // var ir:IFocusable = listView.dataGroup.getItemRendererForIndex(listModel.selectedIndex) as IFocusable; + // ir.setFocus(); + + // (listView as IScrollToIndexView).scrollToIndex(listModel.selectedIndex); + + // sendEvent(listView.host, 'change'); + // } + } + } +} diff --git a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualListView.as b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualListView.as index bc098e5..a53b0aa 100644 --- a/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualListView.as +++ b/frameworks/projects/Jewel/src/main/royale/org/apache/royale/jewel/beads/views/VirtualListView.as @@ -42,7 +42,7 @@ package org.apache.royale.jewel.beads.views * @playerversion AIR 2.6 * @productversion Royale 0.9.7 */ - public class VirtualListView extends VirtualDataContainerView + public class VirtualListView extends VirtualDataContainerView implements IScrollToIndexView { public function VirtualListView() { @@ -153,5 +153,65 @@ package org.apache.royale.jewel.beads.views { } + + /** + * Ensures that the data provider item at the given index is visible. + * + * If the item is visible, the <code>verticalScrollPosition</code> + * property is left unchanged even if the item is not the first visible + * item. If the item is not currently visible, the + * <code>verticalScrollPosition</code> + * property is changed make the item the first visible item, unless there + * aren't enough rows to do so because the + * <code>verticalScrollPosition</code> value is limited by the + * <code>maxVerticalScrollPosition</code> property. + * + * @param index The index of the item in the data provider. + * + * @return <code>true</code> if <code>verticalScrollPosition</code> changed. + * + * @langversion 3.0 + * @playerversion Flash 9 + * @playerversion AIR 1.1 + * @productversion Royale 0.9.7 + */ + public function scrollToIndex(index:int):Boolean + { + // need to be implemented + + // var scrollArea:HTMLElement = (_strand as IStyledUIBase).element; + // var oldScroll:Number = scrollArea.scrollTop; + + // var totalHeight:Number = 0; + // var pm:IListPresentationModel = _strand.getBeadByType(IListPresentationModel) as IListPresentationModel; + + // if(pm.variableRowHeight) + // { + // //each item render can have its own height + // var n:int = listModel.dataProvider.length; + // var irHeights:Array = []; + // for (var i:int = 0; i <= index; i++) + // { + // var ir:IItemRenderer = dataGroup.getItemRendererForIndex(i) as IItemRenderer; + // totalHeight += ir.element.clientHeight; + // irHeights.push(totalHeight + ir.element.clientHeight - scrollArea.clientHeight); + // } + + // scrollArea.scrollTop = Math.min(irHeights[index], totalHeight); + + // } else + // { + // var rowHeight:Number; + // // all items renderers with same height + // rowHeight = isNaN(pm.rowHeight) ? ListPresentationModel.DEFAULT_ROW_HEIGHT : rowHeight; + // totalHeight = listModel.dataProvider.length * rowHeight - scrollArea.clientHeight; + + // scrollArea.scrollTop = Math.min(index * rowHeight, totalHeight); + // } + + // return oldScroll != scrollArea.scrollTop; + + return false; + } } } diff --git a/frameworks/projects/Jewel/src/main/sass/components/_list.sass b/frameworks/projects/Jewel/src/main/sass/components/_list.sass index 7a9dac8..fe08705 100644 --- a/frameworks/projects/Jewel/src/main/sass/components/_list.sass +++ b/frameworks/projects/Jewel/src/main/sass/components/_list.sass @@ -68,4 +68,5 @@ j|ListItemRenderer j|VirtualList IBeadView: ClassReference("org.apache.royale.jewel.beads.views.VirtualListView") IBeadLayout: ClassReference("org.apache.royale.jewel.beads.layouts.VirtualListVerticalLayout") - IDataProviderItemRendererMapper: ClassReference("org.apache.royale.jewel.beads.itemRenderers.VirtualDataItemRendererFactoryForCollectionView") \ No newline at end of file + IDataProviderItemRendererMapper: ClassReference("org.apache.royale.jewel.beads.itemRenderers.VirtualDataItemRendererFactoryForCollectionView") + IBeadKeyController: ClassReference("org.apache.royale.jewel.beads.controllers.VirtualListKeyDownController") \ No newline at end of file