保持“低调” Spark 皮肤按钮的状态
我在按钮组件中使用了带有向上、向下、超过和禁用状态的 Spark 皮肤按钮来创建模块。有没有办法当用户按住某个键时,该按钮将保持“按下”状态?
按钮组件包含皮肤类:
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
skinClass="wfm.keyBtn">
</s:Button>
Spark皮肤:
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
<fx:Metadata>
[HostComponent("spark.components.Button")]
</fx:Metadata>
<s:states>
<s:State name="up"/>
<s:State name="over"/>
<s:State name="down"/>
<s:State name="disabled"/>
</s:states>
<s:Rect width="18" height="80" height.down="83" radiusX="1">
<s:stroke>
<s:SolidColorStroke color="0xaaaaaa" weight="1"/>
</s:stroke>
<s:filters>
<s:BevelFilter
distance="0"
angle="5" angle.down="5"
highlightColor="0xbbbbbb" highlightColor.down="0xaaaaaa"
highlightAlpha="1" highlightAlpha.down="1"
shadowColor="0xaaaaaa" shadowColor.down="0xffffff"
shadowAlpha="1" shadowAlpha.down="1"
blurX="5" blurX.down="6"
blurY="5" blurY.down="6"
strength="2" strength.down="2"
type="inner"
/>
</s:filters>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xf3f3f3" color.down="0xfff963" />
</s:LinearGradient>
</s:fill>
</s:Rect>
</s:SparkSkin>
I have spark skin a button with up, down, over, and disable states in a button component to create a modular. Is there a way when the user press and hold a key, the button will remain in 'down' state?
The button component include skinclass:
<?xml version="1.0" encoding="utf-8"?>
<s:Button xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
skinClass="wfm.keyBtn">
</s:Button>
Spark skin:
<?xml version="1.0" encoding="utf-8"?>
<s:SparkSkin xmlns:fx="http://ns.adobe.com/mxml/2009"
xmlns:s="library://ns.adobe.com/flex/spark"
xmlns:mx="library://ns.adobe.com/flex/mx"
<fx:Metadata>
[HostComponent("spark.components.Button")]
</fx:Metadata>
<s:states>
<s:State name="up"/>
<s:State name="over"/>
<s:State name="down"/>
<s:State name="disabled"/>
</s:states>
<s:Rect width="18" height="80" height.down="83" radiusX="1">
<s:stroke>
<s:SolidColorStroke color="0xaaaaaa" weight="1"/>
</s:stroke>
<s:filters>
<s:BevelFilter
distance="0"
angle="5" angle.down="5"
highlightColor="0xbbbbbb" highlightColor.down="0xaaaaaa"
highlightAlpha="1" highlightAlpha.down="1"
shadowColor="0xaaaaaa" shadowColor.down="0xffffff"
shadowAlpha="1" shadowAlpha.down="1"
blurX="5" blurX.down="6"
blurY="5" blurY.down="6"
strength="2" strength.down="2"
type="inner"
/>
</s:filters>
<s:fill>
<s:LinearGradient rotation="90">
<s:GradientEntry color="0xf3f3f3" color.down="0xfff963" />
</s:LinearGradient>
</s:fill>
</s:Rect>
</s:SparkSkin>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建 Button 的子类,并告诉皮肤在您关心的键按下时处于按下状态。另外,每当您检测到按键按下(或不再按下)时,使皮肤状态无效,以便皮肤知道检查它应该处于什么状态:
Create a subclass of Button and tell the skin to be in the down state whenever the key you care about is down. Also, whenever you detect the key is down (or no longer down), invalidate the skin state so the skin knows to check what state it should be in: