在 Flex 4 中拖动时移动无铬窗口应用程序

发布于 2024-12-02 08:55:48 字数 126 浏览 4 评论 0原文

我在 Flex 4 中实现了一个无边框窗口应用程序。但是这样做时我注意到所有最大化、最小化甚至拖动窗口的功能都消失了。我需要能够拖动窗口。我已经做了很多谷歌搜索,但无法想出任何东西。有人可以指出我正确的方向吗?

提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

魂ガ小子 2024-12-09 08:55:48

您必须为 WindowedApplication 创建自定义皮肤。如果您查看 WindowedApplication 的代码,您会发现这一点:

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

这意味着您可以向皮肤添加 TitleBar,但不是必须这样做。事实上,默认 WindowedApplicationSkin< /a> 没有标题栏。

在自定义皮肤会自动为您提供所需的拖动行为。默认 TitleBarSkin带有常规窗口按钮(最小化、最大化、关闭),因此您可能也想在此处创建自定义皮肤。如果不需要的话,可以选择没有按钮的。

这是一个精简的示例

WindowedApplication 的自定义皮肤(仅白色背景和标题栏):

<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>

TitleBar 的自定义皮肤(仅渐变背景和关闭按钮):

<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>

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

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'.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文