返回介绍

Composite

发布于 2020-10-20 06:58:13 字数 3488 浏览 942 评论 0 收藏 0

Extends Widget

An empty widget that can contain other widgets.

Import this type with “const {Composite} = require('tabris');

Methods

append(…widgets)

Parameters:

  • …widgets: Widget[]

Returns: this

Adds the given widgets to the composite.

append(widgets)

Parameters:

  • widgets: Widget[]

Returns: this

Adds all widgets in the given array to the composite.

append(widgets)

Parameters:

  • widgets: WidgetCollection

Returns: this

Adds all widgets in the given collection to the composite.

Properties

padding

Type: *BoxDimensionsnumber*, default: 0

Additional space to add inside the widget’s bounds. If set to a number, this padding will be applied on all four sides.

Events

addChild

Fired when a child is added to this widget.

Event Parameters

  • target: this The widget the event was fired on.

  • child: Widget The widget that is added as a child.

  • index: number Denotes the position in the children list at which the child widget is added.

paddingChanged

Fired when the padding property has changed.

Event Parameters

  • target: this The widget the event was fired on.

  • value: BoxDimensions|number The new value of padding.

removeChild

Fired when a child is removed from this widget.

Event Parameters

  • target: this The widget the event was fired on.

  • child: Widget The widget that is removed.

  • index: number The property index denotes the removed child widget’s position in the children list.`

Example

const {Composite, TextView, ui} = require('tabris');

// Create composites and append children to them

let composite1 = new Composite({
  left: 0, top: 0, bottom: 0, right: '50%',
  background: '#f3f3f3'
}).appendTo(ui.contentView);

new TextView({
  left: 0, right: 0, top: '50%',
  alignment: 'center',
  text: 'Composite 1'
}).appendTo(composite1);

let composite2 = new Composite({
  left: '50%', top: 0, bottom: 0, right: 0,
  background: '#eaeaea'
}).appendTo(ui.contentView);

new TextView({
  left: 0, right: 0, top: '50%',
  alignment: 'center',
  text: 'Composite 2'
}).appendTo(composite2);

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文