快速了解滚动条来源的方法?

发布于 2024-11-06 05:04:59 字数 255 浏览 6 评论 0原文

每当我在 mxml 组件(包括许多状态)中使用大量嵌套以及相当多的 Vbox 和其他容器时,当我看到屏幕上出现滚动条时,我总是感到困惑,尤其是其中包含数据网格(我总是想显示滚动条)在 datagrid 中而不是在父容器上,为此我通常在运行时将 datagrid 的高度和宽度设置为小于其父容器)。

我的问题是,使用调试器,我怎么可能(快速)知道哪个组件是我在屏幕上看到的滚动条的来源(如果有多个组件,那么当我向上滚动它时,组件的某些属性必须改变)或向下)。

谢谢。

Whenever I use a lot of nesting inside mxml components(including many states) with quite a few Vboxs and Other containers, I always get confused when I see a scrollbar appearing on screen, especially with datagrid inside it(I always want to show scroll bar in datagrid and not on the parent container, for which I usually set the height and width of datagrid smaller than its parent container at run time).

My question is, how could I possibly know (QUICKLY), using debugger, that which component is the source of scroll bar that I see on screen (if there are more than one, then some propoerty of compnent must change when I scroll it up or down).

Thanks.

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

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

发布评论

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

评论(1

青衫儰鉨ミ守葔 2024-11-13 05:04:59

我意识到这个答案没有直接使用调试器。我的意思是,它确实是一个简单工具的想法。

我快速组合了一个简单的应用程序,其功能是报告哪个显示对象正在调度鼠标滚轮事件。是否有滚动条对应用程序来说并不重要,但我想您可以根据您的需要进行调整。它确实是一个快速启动,这是代码...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600"
                creationComplete="init()">
    <mx:HBox id="HBoxWithScrollbar" width="600" height="500">
        <mx:HBox width="800" height="800">
        </mx:HBox>
    </mx:HBox>
    <mx:TextArea id="record" height="300" width="600"/>
    <mx:Script>
        <![CDATA[
            private function init():void{
                record.text = 'Scroll Record\n';
                this.addEventListener(MouseEvent.MOUSE_WHEEL, recordObject);
                for each (var obj:DisplayObject in this.getChildren()){
                    obj.addEventListener(MouseEvent.MOUSE_WHEEL, recordObject);
                }
            }

            protected function recordObject(event:MouseEvent):void{
                record.text += (event.target as DisplayObject).toString() + '\n';
            }

        ]]>
    </mx:Script>
</mx:Application>

这里重要的是要看到您可以在顶层拾取鼠标滚轮事件,因为它默认情况下会冒泡,并且不可取消。

http://help.adobe .com/en_US/FlashPlatform/reference/actionscript/3/flash/display/InteractiveObject.html#event:mouseWheel

一旦你掌握了该事件,你就得到了 选项。

这是使用 Flex SDK 3.6 版本构建的,但构建 4.x 版本不需要太多时间。我只是显示目标显示对象的“toString()”值,但这可以是您想要的任何属性。您可能需要为添加事件的循环以及事件处理程序添加一些错误处理。正如我所说,这只是一个开始,我希望它能有所帮助。

I realise that this answer isn't using the debugger directly. I mean it as an idea for a simple tool really.

I had a quick go at putting together a simple app that's function is to report what display object is dispatching a mouse wheel event. It does not matter to the app if there is a scrollbar or not, but I guess you could adjust it to your needs. Its a quick start really, here's the code...

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml" layout="vertical" minWidth="955" minHeight="600"
                creationComplete="init()">
    <mx:HBox id="HBoxWithScrollbar" width="600" height="500">
        <mx:HBox width="800" height="800">
        </mx:HBox>
    </mx:HBox>
    <mx:TextArea id="record" height="300" width="600"/>
    <mx:Script>
        <![CDATA[
            private function init():void{
                record.text = 'Scroll Record\n';
                this.addEventListener(MouseEvent.MOUSE_WHEEL, recordObject);
                for each (var obj:DisplayObject in this.getChildren()){
                    obj.addEventListener(MouseEvent.MOUSE_WHEEL, recordObject);
                }
            }

            protected function recordObject(event:MouseEvent):void{
                record.text += (event.target as DisplayObject).toString() + '\n';
            }

        ]]>
    </mx:Script>
</mx:Application>

The important thing here really is to see that you can pick up the mouse wheel event at the top level, because it bubbles by default, and isn't cancelable.

http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/flash/display/InteractiveObject.html#event:mouseWheel

Once you've got hold of that event, you've got options.

This was built using version 3.6 of the Flex SDK, but it wouldn't take much to build a 4.x version. I am simply displaying "toString()" value of the target display object, but that could be any attribute you want. You'll probably want to put in some error handling for the loop adding events, and also in the event handler. As I said, its just a start, and I hope it helps.

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