styleManager:使用 setStyleDeclaration 时出现问题
嘿伙计们..!!
我正在使用 styleManager.setStyleDeclaration 为同一组件的多个实例设置 CssStyleDeclaration 对象,该组件在不同的画布中使用。
我想在不同的画布中设置该组件的不同属性,但我想这不会发生,因为 setStyleDeclaration 获取组件的名称并全局设置样式。
以下是第一个cssstyledeclaration:
this.dataTickerOddStyle = new CSSStyleDeclaration();
this.dataTickerOddStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o.DataTicker.Item[0].Background_Fill_Colors));
this.dataTickerOddStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Fill_Alphas));
this.dataTickerOddStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Gradient_Ratios));
this.dataTickerOddStyle.setStyle("cornerRadius", int(o.DataTicker.Item[0].Background_Corner_Radius));
this.dataTickerOddStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o.DataTicker.Item[0].Background_Border_Color));
this.dataTickerOddStyle.setStyle("borderThickness", Number(o.DataTicker.Item[0].Background_Border_Thickness));<br>
这就是我使用它的方式:
this.styleManager.setStyleDeclaration("com.GradientCanvas",WidgetStylesheet.instance.dataTickerOddStyle, true);
另一个cssstyledeclaration是:
this.m_zoneBackgroundStyle = new CSSStyleDeclaration();
this.m_zoneBackgroundStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o["Background_Fill_Alphas"]));
this.m_zoneBackgroundStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o["Background_Fill_Colors"]));
this.m_zoneBackgroundStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o["Background_Gradient_Ratios"]));
this.m_zoneBackgroundStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o["Background_Border_Color"]));
this.m_zoneBackgroundStyle.setStyle("borderThickness", Number(o["Background_Border_Thickness"]));
this.m_zoneBackgroundStyle.setStyle("cornerRadius", Number(o["Background_Corner_Radius"]));
为此我使用以下内容:
this.fill.styleManager.setStyleDeclaration("com.GradientCanvas", AppStylesheet.instance.m_zoneBackgroundStyle, true);<br>
请注意,我使用相同的选择器/组件..请帮我解决这个问题..提前谢谢
Hey folks..!!
I m using styleManager.setStyleDeclaration to set the CssStyleDeclaration object for more then one instance of the same component, that is being used in different canvases.
I want to set different properties of this component in various canvases, but it wont happen as setStyleDeclaration takes name of the component and set styles to it globally, i suppose.
following is the first cssstyledeclaration:
this.dataTickerOddStyle = new CSSStyleDeclaration();
this.dataTickerOddStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o.DataTicker.Item[0].Background_Fill_Colors));
this.dataTickerOddStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Fill_Alphas));
this.dataTickerOddStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o.DataTicker.Item[0].Background_Gradient_Ratios));
this.dataTickerOddStyle.setStyle("cornerRadius", int(o.DataTicker.Item[0].Background_Corner_Radius));
this.dataTickerOddStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o.DataTicker.Item[0].Background_Border_Color));
this.dataTickerOddStyle.setStyle("borderThickness", Number(o.DataTicker.Item[0].Background_Border_Thickness));<br>
This is how i ve used it:
this.styleManager.setStyleDeclaration("com.GradientCanvas",WidgetStylesheet.instance.dataTickerOddStyle, true);
and another cssstyledeclaration is:
this.m_zoneBackgroundStyle = new CSSStyleDeclaration();
this.m_zoneBackgroundStyle.setStyle("fillAlphas", StringUtilEx.ExtractNumberPair(o["Background_Fill_Alphas"]));
this.m_zoneBackgroundStyle.setStyle("fillColors", StringUtilEx.ExtractColorPair(o["Background_Fill_Colors"]));
this.m_zoneBackgroundStyle.setStyle("gradientRatio", StringUtilEx.ExtractNumberPair(o["Background_Gradient_Ratios"]));
this.m_zoneBackgroundStyle.setStyle("borderColor", StringUtilEx.ConvertToColor(o["Background_Border_Color"]));
this.m_zoneBackgroundStyle.setStyle("borderThickness", Number(o["Background_Border_Thickness"]));
this.m_zoneBackgroundStyle.setStyle("cornerRadius", Number(o["Background_Corner_Radius"]));
and for this i use following:
this.fill.styleManager.setStyleDeclaration("com.GradientCanvas", AppStylesheet.instance.m_zoneBackgroundStyle, true);<br>
Notice that i m using same selector/component..Please help me out on this..thanx in advance
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我解决了这个问题。我之前使用的是
类型选择器
,而不是类选择器
。I resolved the problem. I was using
Type Selector
before, instead ofClass Selector
.(不确定我完全理解你的意思……但是……)
您可以在单个组件实例上设置样式,而无需更改全局样式。
而不是
(not sure I fully understand what you're getting at.. but.. )
You can set the style on a single component instance without changing the global style.
instead of