简体   繁体   English

Adobe Flex / Actionscript:可编辑标签

[英]Adobe Flex/Actionscript: editable label

I am working on a project where it would be really nice if we had editbale labels or an area for TextInput that looks like a Label if it isnt hovered with the mouse. 我正在做一个项目,如果我们有editbale标签,或者如果TextInput的区域没有用鼠标悬停,则它看起来会像Label一样,这真的很好。

I'm pretty new at Flex, and dont know how to develop a skin. 我在Flex刚起步,不知道如何开发皮肤。 I dont even know if it possible to do this just by skinning. 我什至不知道是否可能仅通过剥皮就可以做到这一点。

Anyhow, I found this question from a few months ago but i cant get it working, it just displays a empty white page. 无论如何,我几个月前就发现了这个问题,但我无法正常工作,它只显示一个空白页面。

Here the code I used to create a editable Label mentioned in the link above: 这是我在上面的链接中提到的用于创建可编辑标签的代码:

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" 
           xmlns:s="library://ns.adobe.com/flex/spark" 
           xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:component="com.npacemo.component.*"
           xmlns:skins="skins.*">
<fx:Declarations>
    <!-- Platzieren Sie nichtvisuelle Elemente (z. B. Dienste, Wertobjekte) hier -->
</fx:Declarations>
<s:BorderContainer>     
    <component:EditableLabel text="Text 132"  skinClass="skins.EditableLabel" />
</s:BorderContainer>

</s:Application>

Any idea why the displayed page is empty? 知道为什么显示的页面为空吗? Or a different approach? 还是其他方法?

Thanks in advance, markus 预先感谢,马库斯

I encountered the same problem about this editable label. 我遇到了与此可编辑标签相同的问题。
I think the root cause was from SkinPart:labelComponent . 我认为根本原因来自SkinPart:labelComponent Inside the skin, the label was like this: 在皮肤内部,标签如下:

<s:Label id="labelComponent" text="{hostComponent.text}"
         alpha.normal="1" alpha.selected="0" 
         visible.normal="true" visible.selected="false"
         verticalCenter="0" width="{this.width+20}" maxDisplayedLines="1"
         textDecoration="underline" buttonMode="true"/>

Since the width setting was causing a self-reference loop, label would throw the exception. 由于宽度设置导致自引用循环,因此标签会引发异常。 The solution here is just clear the width setting: 这里的解决方案是清除宽度设置:

<s:Label id="labelComponent" text="{hostComponent.text}"
         alpha.normal="1" alpha.selected="0" 
         visible.normal="true" visible.selected="false"
         verticalCenter="0" maxDisplayedLines="1"
         textDecoration="underline" buttonMode="true"/>

And the component can be displayed now. 现在可以显示该组件。
I found there's a difference between displaying components in Application and View. 我发现在“ Application和“视图”中显示组件之间存在差异。 In Application , some exceptions are caught automatically, making the process of debugging become more difficult. Application ,某些异常会自动捕获,从而使调试过程变得更加困难。
Hope this would help! 希望这会有所帮助!

In a project we were working on we did editable labels by using a textbox and remove background and borders (it will look just like a label and will be editable). 在一个我们正在研究的项目中,我们使用文本框做了可编辑的标签,并删除了背景和边框(它看起来就像一个标签,并且是可编辑的)。 In your case you can do this and then on mouseIn you can show the border and background again (making it look like a text box) and then MouseOut with removing til style again. 在您的情况下,您可以执行此操作,然后在mouseIn上再次显示边框和背景(使其看起来像文本框),然后在MouseOut上再次删除til样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM