This is an automated email from the ASF dual-hosted git repository.
gregdove 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 a1611cb Adding support for styleName assignments via string values in
MXRoyale. Setting styleName as a string value will add the specific assigned
value into the element's classList in JS, allowing for some aspects of styling
similar to how it worked in Flex for string assignments.
a1611cb is described below
commit a1611cba9bafdc3af579f08dbd1df1ce625b5a08
Author: greg-dove <[email protected]>
AuthorDate: Fri May 8 21:19:53 2020 +1200
Adding support for styleName assignments via string values in MXRoyale.
Setting styleName as a string value will add the specific assigned value
into the element's classList in JS, allowing for some aspects of styling
similar to how it worked in Flex for string assignments.
---
.../AdvancedDataGridItemRenderer.as | 22 ++++++++++++++++
.../dataGridClasses/DataGridItemRenderer.as | 22 ++++++++++++++++
.../src/main/royale/mx/core/UIComponent.as | 30 +++++++++++++++++++---
3 files changed, 70 insertions(+), 4 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 e4478e2..fe66dee 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
@@ -256,6 +256,14 @@ public class AdvancedDataGridItemRenderer extends
StringItemRenderer
// styleName
//----------------------------------
+ COMPILE::JS
+ override protected function computeFinalClassNames():String
+ {
+ var computed:String = super.computeFinalClassNames();
+ if (typeof _styleName == 'string') computed += ' ' + _styleName;
+ return computed;
+ }
+
/**
* @private
* Storage for the styleName property.
@@ -285,6 +293,20 @@ public class AdvancedDataGridItemRenderer extends
StringItemRenderer
_styleName = value;
+ if (typeof value == 'string' || !value) {
+ COMPILE::JS{
+ if (_styleName) element.classList.remove(_styleName);
+ _styleName = value;
+ if (value) element.classList.add(value)
+ }
+ COMPILE::SWF{
+ trace("styleName not yet implemented for string assignments");
+ }
+ } else {
+ // TODO
+ trace("styleName not implemented for non-string assignments");
+ }
+
/*
if (parent)
{
diff --git
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/dataGridClasses/DataGridItemRenderer.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/dataGridClasses/DataGridItemRenderer.as
index c8e1499..d99d561 100644
---
a/frameworks/projects/MXRoyale/src/main/royale/mx/controls/dataGridClasses/DataGridItemRenderer.as
+++
b/frameworks/projects/MXRoyale/src/main/royale/mx/controls/dataGridClasses/DataGridItemRenderer.as
@@ -233,6 +233,14 @@ public class DataGridItemRenderer extends
StringItemRenderer
// styleName
//----------------------------------
+ COMPILE::JS
+ override protected function computeFinalClassNames():String
+ {
+ var computed:String = super.computeFinalClassNames();
+ if (typeof _styleName == 'string') computed += ' ' + _styleName;
+ return computed;
+ }
+
/**
* @private
* Storage for the styleName property.
@@ -261,6 +269,20 @@ public class DataGridItemRenderer extends
StringItemRenderer
return;
_styleName = value;
+ if (typeof value == 'string' || !value) {
+ COMPILE::JS{
+ if (_styleName) element.classList.remove(_styleName);
+ _styleName = value;
+ if (value) element.classList.add(value)
+ }
+ COMPILE::SWF{
+ trace("styleName not yet implemented for string assignments");
+ }
+ } else {
+ // TODO
+ trace("styleName not implemented for non-string assignments");
+ }
+
/*
if (parent)
diff --git
a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
index 79d9d5c..c9819eb 100644
--- a/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
+++ b/frameworks/projects/MXRoyale/src/main/royale/mx/core/UIComponent.as
@@ -104,6 +104,8 @@ import org.apache.royale.utils.MXMLDataInterpreter;
import mx.managers.IFocusManagerComponent;
import mx.events.FocusEvent;
+import org.apache.royale.utils.ClassSelectorList;
+
/**
* Set a different class for click events so that
* there aren't dependencies on the flash classes
@@ -3262,11 +3264,22 @@ COMPILE::JS
// styleName
//----------------------------------
+
+ //
+ COMPILE::JS
+ override protected function computeFinalClassNames():String
+ {
+ var computed:String = super.computeFinalClassNames();
+ if (typeof _styleName == 'string') computed += ' ' + _styleName;
+ return computed;
+ }
+
/**
* @private
* Storage for the styleName property.
*/
private var _styleName:Object /* String, CSSStyleDeclaration, or
UIComponent */;
+ private var _classSelectorList:ClassSelectorList; //implementation support
for styleName string values
[Inspectable(category="General")]
@@ -3301,11 +3314,20 @@ COMPILE::JS
{
if (_styleName === value)
return;
+ if (typeof value == 'string' || !value) {
+ COMPILE::JS{
+ if (_styleName) element.classList.remove(_styleName);
+ _styleName = value;
+ if (value) element.classList.add(value)
+ }
+ COMPILE::SWF{
+ trace("styleName not yet implemented for string assignments");
+ }
+ } else {
+ // TODO
+ trace("styleName not implemented for non-string assignments");
+ }
- _styleName = value;
-
- // TODO
- trace("styleName not implemented");
}
//----------------------------------