在flex中拖动无铬窗口应用程序4 [英] move chromeless windowedapplication on drag in flex 4

查看:197
本文介绍了在flex中拖动无铬窗口应用程序4的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在flex 4中实现了一个无铬的窗口应用程序。但是,我注意到所有的最大化,最小化,甚至是拖动窗口的能力都没有了。我需要能够拖动窗口。我做了大量的搜索,并没有任何东西。

解决方案

您必须为您的WindowedApplication创建自定义外观。如果你看看WindowedApplication的代码,你会发现:
$ b

  [SkinPart(required =false)] 
public var titleBar:TitleBar;

这意味着您可以将标题栏添加到皮肤,但您不必。事实上,默认的 WindowedApplicationSkin 没有titleBar。



包含 TitleBar 在自定义外观中会自动为您提供拖动行为。默认的 TitleBarSkin 随着常规窗口按钮(最小化,最大化,关闭),所以你可能也想在这里创建一个自定义皮肤。一个没有按钮,如果你不需要它们。

这是一个精简的示例

WindowedApplication的自定义外观(只是一个白色背景和一个TitleBar):

 < s:Skin xmlns :fx =http://ns.adobe.com/mxml/2009
xmlns:s =library://ns.adobe.com/flex/spark>

< fx:Metadata> [HostComponent(Object)]< / fx:Metadata>

< s:州>
< / s:州>

< s:Rect id =backgroundRectleft =0right =0top =0bottom =0>
< s:fill>
< s:SolidColor id =backgroundFillcolor =0xffffff/>
< / s:fill>
< / s:Rect>

skinClass =skin.TitleBarSkin/>


< / s:Skin>

TitleBar的自定义外观(只是渐变背景和关闭按钮):

 < s:Skin xmlns:fx =http://ns.adobe.com/mxml/2009
xmlns: s =library://ns.adobe.com/flex/spark
minHeight =24>

< fx:元数据>
[HostComponent(spark.components.windowClasses.TitleBar)]
< / fx:Metadata>

< s:州>
< s:国家名称=normalAndMaximized/>
< / s:州>

< s:Rect id =backgroundleft =0right =0top =0bottom =0>
< s:fill>
< s:LinearGradient rotation =90>
< s:GradientEntry color =0xBABABA/>
< / s:LinearGradient>
< / s:fill>
< / s:Rect>


< / s:Skin>

显然,'closeButton'是必需的,因此您必须将其包含在皮肤中。但是,如果你仍然想摆脱它,只需将它的'visible'和'includeInLayout'属性设置为'false'。


I have implemented a chromeless windowedapplication in flex 4. But doing so i noticed that all the maximize, minimize and even the ability to drag the window around is gone. I need the ability to drag the window around. I have done a lot of googling and have been unable to come up with anything. Could somebody plz point me in the right direction.

Thanks in advance.

解决方案

You'll have to create a custom skin for your WindowedApplication. If you look in the code of WindowedApplication, you'll find this:

[SkinPart (required="false")]
public var titleBar:TitleBar;

which means you can add a TitleBar to the skin, but you don't have to. As a matter of fact the default WindowedApplicationSkin doesn't have a titleBar.

Including a TitleBar in the custom skin will automatically give you the dragging behavior you're after. The default TitleBarSkin comes with the regular window buttons (minimize, maximize, close), so you may want to create a custom skin here too. One without the buttons if you don't need them.

Here's a stripped down example.

The custom skin for WindowedApplication (just a white background and a TitleBar):

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" >

    <fx:Metadata>[HostComponent("Object")]</fx:Metadata>

    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
        <s:State name="normalAndInactive" />
        <s:State name="disabledAndInactive" />
    </s:states>

    <s:Rect id="backgroundRect" left="0" right="0" top="0" bottom="0" >
        <s:fill>
            <s:SolidColor id="backgroundFill" color="0xffffff" />
        </s:fill>
    </s:Rect>

    <s:TitleBar left="0" right="0" top="0" height="24" 
                skinClass="skin.TitleBarSkin" />

    <s:Group id="contentGroup" left="0" right="0" top="25" bottom="0" />

</s:Skin>

The custom skin for your TitleBar (just a gradient background and a close button):

<s:Skin xmlns:fx="http://ns.adobe.com/mxml/2009" 
        xmlns:s="library://ns.adobe.com/flex/spark" 
        minHeight="24" >

    <fx:Metadata>
      [HostComponent("spark.components.windowClasses.TitleBar")]
    </fx:Metadata> 

    <s:states>
        <s:State name="normal" />
        <s:State name="disabled" />
        <s:State name="normalAndMaximized" />
        <s:State name="disabledAndMaximized" />
    </s:states>

    <s:Rect id="background" left="0" right="0" top="0" bottom="0">
        <s:fill>
            <s:LinearGradient rotation="90">
                <s:GradientEntry color="0xFFFFFF" />
                <s:GradientEntry color="0xBABABA" />
            </s:LinearGradient>
        </s:fill>
    </s:Rect>

    <s:Button id="closeButton" label="close" right="0" verticalCenter="0" />

</s:Skin>

Apparently, the 'closeButton' is required, so you'll have to include it in the skin. But if you still want to get rid of it, just set its 'visible' and 'includeInLayout' properties to 'false'.

这篇关于在flex中拖动无铬窗口应用程序4的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆