有没有办法在 Flex 3 中设置滚动条拇指的 minHeight

发布于 2024-08-16 03:45:00 字数 644 浏览 5 评论 0原文

在我的项目中,我们需要使滚动条看起来像 Windows 滚动条。

因此,我在垂直滚动条的拇指上有一个thumbIcon,但是如果我在组合框中获得太多项目,则滚动条会变得很繁琐。这是因为thumbIcon 和thumbSkin 边框之间的边距太小。

有没有办法设置thumbSkin的最小高度,以便我可以确保那里总是有边距并且它总是看起来不错,即使有太多项目?

繁琐的滚动条 http://img97.imageshack.us/img97/7057/nomargins.gif

上图中,看到拇指了吗?我所说的“thumbIcon”是指 3 条水平线。该图标与拇指本身边框之间的顶部和底部边距太小。

普通滚动条 http://img15.imageshack.us/img15/5527/margins.gif

这是正常的滚动条,thumbIcon和thumb的边框有足够的边距,这使得滚动条看起来好看很多。

In my project we needed to make the scollbars look like Windows scrollbars.

Therefore I have a thumbIcon on the thumb of a vertical scrollbar, but if I get too many items in the combobox, the scrollbar gets fiddly. This is because the margin between the thumbIcon and the border of the thumbSkin is too small.

Is there a way to set the minimum height of the thumbSkin so that I can ensure there is always a margin there and it always looks good, even if there are too many items?

Fiddly scroll bar http://img97.imageshack.us/img97/7057/nomargins.gif

Image above, see the thumb? By the thumbIcon I mean the 3 horizontal lines. The top and bottom margin between this icon and the border of the thumb itself is too small.

Normal scroll bar http://img15.imageshack.us/img15/5527/margins.gif

This is the normal scroll bar, the thumbIcon and the borders of the thumb have enough margin, which make the scroll bar look a lot better.

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

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

发布评论

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

评论(3

煞人兵器 2024-08-23 03:45:00

您应该能够扩展(或者如果您真的很勇敢,可以编辑)ScrollThumb 类,其中的最小高度设置为 10,我同意这个值相当小。

然后,您将需要扩展scrollBar 类并设置thumbUpSkin 的样式以使用新扩展的ScrollThumb 类。

最后,您将需要扩展下拉控件以使用新的扩展滚动条类。

我会更具体,但我对扩展类和覆盖东西还不满意,也许更擅长这一点的人会在这里看到我的答案并给出一个很好的代码示例。

编辑类有一个优点,因为您不必扩展所有其他涉及的类,但缺点是在 SDK 上编译的项目中的每个 ScrollBar 都将使用新的最小高度设置,并且如果它是用一个“原始”的 SDK(可能是由同事创建的),无论该 SDK 中的设置是什么,都可能导致将来出现一些非常困难的故障排除。

You should be able to extend (or if you feel really brave, edit) the ScrollThumb class, there's a minimum height setting in there of 10, which I agree is quite small.

Then you will want to extend the scrollBar class and set the style of the thumbUpSkin of to use that new extended ScrollThumb class.

Finaly you will want to extend your dropdown control to use the new extended scrollBar class.

I'd be more specific, but I'm not comfortable with extending classes and overriding stuff yet, maybe someone better at that will see my answer here and give a good code example.

There's an advantage to editing the class, in that you won't have to then extend all the other classes involved, but the disadvantage is that every ScrollBar in projects compiled on your SDK will use your new minimum height setting, and if it's compiled with a "pristine" SDK (maybe by a co-worker) it would be whatever the setting is in that SDK which could lead to some really difficult trouble-shooting in the future.

樱花落人离去 2024-08-23 03:45:00

重写这些类的另一种方法是获取对scrollThumb 的引用作为ScrollBar 的子级。

        var scrollThumb:ScrollThumb = hScrollBar.getChildAt(2) as ScrollThumb;
        scrollThumb.minHeight = 50;

这并不理想,因为它依赖于 ScrollThumb 的索引,但我怀疑这可能会改变,而且它比覆盖 Flex 类更简单。

An alternative to overriding the classes is to get a reference to the the scrollThumb as a child of the ScrollBar.

        var scrollThumb:ScrollThumb = hScrollBar.getChildAt(2) as ScrollThumb;
        scrollThumb.minHeight = 50;

This is not ideal as it's dependent on the index of the ScrollThumb but I doubt that's likely to change and it's simpler than overriding the flex classes.

云醉月微眠 2024-08-23 03:45:00

这是我找到的用于强制滚动滑块最小尺寸的解决方案。我扩展了 HScrollBar 和 VScrollBar 并覆盖了 setScrollProperties 方法,以设置最小大小。以下是 HScrollBar 版本:

package your.package
{
import mx.controls.HScrollBar;
import mx.core.mx_internal;

use namespace mx_internal;

public class LargeThumbHScrollBar extends HScrollBar
{
    public function LargeThumbHScrollBar()
    {
        super();
    }

    public override function setScrollProperties(pageSize:Number,
                                        minScrollPosition:Number,
                                        maxScrollPosition:Number,
                                        pageScrollSize:Number = 0):void
    {
        super.setScrollProperties(pageSize, minScrollPosition, maxScrollPosition, pageScrollSize);

        if (scrollThumb) {
            scrollThumb.explicitMinHeight = 100;
        }
    }

}
}

对于 HScrollBar 和 VScrollBar,您都设置explicitMinHeight(不要在任一版本中设置explicitMinWidth)。

不过,我不确定如何获取组件的默认滚动条以使用子类。我不必解决这个问题,因为我们自己添加了滚动条。快速谷歌搜索没有找到任何答案。

Here is the solution I found for enforcing a minimum size for the scroll thumb. I extended HScrollBar and VScrollBar and overrode the setScrollProperties method, to set the minimum size. Here is the HScrollBar version:

package your.package
{
import mx.controls.HScrollBar;
import mx.core.mx_internal;

use namespace mx_internal;

public class LargeThumbHScrollBar extends HScrollBar
{
    public function LargeThumbHScrollBar()
    {
        super();
    }

    public override function setScrollProperties(pageSize:Number,
                                        minScrollPosition:Number,
                                        maxScrollPosition:Number,
                                        pageScrollSize:Number = 0):void
    {
        super.setScrollProperties(pageSize, minScrollPosition, maxScrollPosition, pageScrollSize);

        if (scrollThumb) {
            scrollThumb.explicitMinHeight = 100;
        }
    }

}
}

For both HScrollBar and VScrollBar you set the explicitMinHeight (don't set explicitMinWidth in either version).

I'm not sure how to get the default scrollbars for a component to use the subclasses, though. I didn't have to tackle that problem because we were adding the scrollbars on ourselves. A quick google search didn't turn up any answers.

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