Skip to content

Commit

Permalink
learn: some fixes and general improvements for data containers
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Dec 6, 2024
1 parent 74ca1f0 commit 227fcb8
Show file tree
Hide file tree
Showing 9 changed files with 138 additions and 41 deletions.
2 changes: 1 addition & 1 deletion learn/haxe-openfl/button-bar.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ buttons.itemToText = function(item:Dynamic):String {
};
```

> Items in the collection are not required to be simple object literals, like in the example above. Instances of a class are allowed too (and encouraged as a best practice).
> Items in the collection are _not_ required to be [anonymous structures](https://haxe.org/manual/types-anonymous-structure.html), like in the example above. [Class instances](https://haxe.org/manual/types-class-instance.html) are allowed too (and encouraged as a best practice; you should prefer classes over anonymous structures).
[Add an event listener](https://books.openfl.org/openfl-developers-guide/handling-events/basics-of-handling-events.html) for [`ButtonBarEvent.ITEM_TRIGGER`](https://api.feathersui.com/current/feathers/events/ButtonBarEvent.html#ITEM_TRIGGER) to perform an action when the user clicks or taps a button.

Expand Down
4 changes: 3 additions & 1 deletion learn/haxe-openfl/combo-box.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,9 @@ comboBox.itemToText = function(item:Dynamic):String {
};
```

> Items in the collection are not required to be simple object literals, like in the example above. Instances of a class are allowed too (and encouraged as a best practice).
> Items in the collection are _not_ required to be [anonymous structures](https://haxe.org/manual/types-anonymous-structure.html), like in the example above. [Class instances](https://haxe.org/manual/types-class-instance.html) are allowed too (and encouraged as a best practice; you should prefer classes over anonymous structures).
### Selection

[Add an event listener](https://books.openfl.org/openfl-developers-guide/handling-events/basics-of-handling-events.html) for [`Event.CHANGE`](https://api.openfl.org/openfl/events/Event.html#CHANGE) to perform an action when the user selects a different item.

Expand Down
4 changes: 2 additions & 2 deletions learn/haxe-openfl/grid-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ gridView.columns = new ArrayCollection([

The first parameter of the [`GridViewColumn`](https://api.feathersui.com/current/feathers/controls/GridViewColumn.html) is the text to display in each column header. The second parameter is passed to the [`itemToText()`](https://api.feathersui.com/current/feathers/controls/GridViewColumn.html#itemToText) property, which is a function that returns the text to display in a cell renderer.

> Items in the collection are not required to be simple object literals, like `{ item: "Bacon", dept: "Meat", price: "4.49" }` in the example above. Instances of a class are allowed too (and encouraged as a best practice).
> Items in the collection are _not_ required to be [anonymous structures](https://haxe.org/manual/types-anonymous-structure.html), like `{ item: "Bacon", dept: "Meat", price: "4.49" }` in the example above. [Class instances](https://haxe.org/manual/types-class-instance.html) are allowed too (and encouraged as a best practice; you should prefer classes over anonymous structures).
### Selection

Expand Down Expand Up @@ -147,7 +147,7 @@ var recycler = DisplayObjectRecycler.withFunction(() -> {
});
```

> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom cell renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and all other Feathers UI components.
> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom cell renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and [all other Feathers UI components](./ui-components.md).
Both [`GridView`](https://api.feathersui.com/current/feathers/controls/GridView.html) and [`GridViewColumn`](https://api.feathersui.com/current/feathers/controls/GridViewColumn.html) define `cellRendererRecycler` properties. On [`GridViewColumn`](https://api.feathersui.com/current/feathers/controls/GridViewColumn.html), the [`cellRendererRecycler`](https://api.feathersui.com/current/feathers/controls/GridViewColumn.html#cellRendererRecycler) property may be used to customize the cell renderers in that specific column. On [`GridView`](https://api.feathersui.com/current/feathers/controls/GridView.html), the [`cellRendererRecycler`](https://api.feathersui.com/current/feathers/controls/GridView.html#cellRendererRecycler) property may be used to customize the default cell renderers used when a particular column doesn't have a specific cell renderer.

Expand Down
8 changes: 4 additions & 4 deletions learn/haxe-openfl/group-list-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ var collection = new ArrayHierarchicalCollection( [
groupListView.dataProvider = collection;
```

Set the collection's [`itemToChildren()`](https://api.feathersui.com/current/feathers/controls/ArrayHierarchicalCollection.html#itemToChildren) method to get the children from each branch that need to be rendered by the tree view.
Set the collection's [`itemToChildren()`](https://api.feathersui.com/current/feathers/data/ArrayHierarchicalCollection.html#itemToChildren) method to get the children from each branch that need to be rendered by the tree view.

```haxe
collection.itemToChildren = (item:Dynamic) -> item.children;
Expand All @@ -71,7 +71,7 @@ Additionally, set the [`itemToHeaderText()`](https://api.feathersui.com/current/
groupListView.itemToHeaderText = (group:Dynamic) -> group.headerText;
```

> Items in the collection are not required to be simple object literals, like `{text: "Node A1"}` in the example above. Instances of a class are allowed too (and encouraged as a best practice). If you use a class, be sure to update the item parameter's type in the `itemToChildren`, `itemToText`, and `itemToHeaderText` functions so that the compiler can catch any errors.
> Items in the collection are _not_ required to be [anonymous structures](https://haxe.org/manual/types-anonymous-structure.html), like `{text: "Node A1"}` in the example above. [Class instances](https://haxe.org/manual/types-class-instance.html) are allowed too (and encouraged as a best practice; you should prefer classes over anonymous structures). If you use a class, be sure to update the item parameter's type in the `itemToChildren`, `itemToText`, and `itemToHeaderText` functions so that the compiler can catch any errors.
### Selection

Expand All @@ -86,7 +86,7 @@ Check for the new value of the [`selectedItem`](https://api.feathersui.com/curre
```haxe
function groupListView_changeHandler(event:Event):Void {
var groupListView = cast(event.currentTarget, GroupListView);
trace("GroupListView selectedItem change: " + groupListView.selectedItem.data.text);
trace("GroupListView selectedItem change: " + groupListView.selectedItem.text);
}
```

Expand Down Expand Up @@ -158,7 +158,7 @@ var recycler = DisplayObjectRecycler.withFunction(() -> {
});
```

> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom item renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and all other Feathers UI components.
> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom item renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and [all other Feathers UI components](./ui-components.md).
Pass the [`DisplayObjectRecycler`](https://api.feathersui.com/current/feathers/utils/DisplayObjectRecycler.html) to the [`itemRendererRecycler`](https://api.feathersui.com/current/feathers/controls/GroupListView.html#itemRendererRecycler) property.

Expand Down
4 changes: 2 additions & 2 deletions learn/haxe-openfl/list-view.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ listView.itemToText = function(item:Dynamic):String {
};
```

> Items in the collection are not required to be simple object literals, like `{ text: "A" }` in the example above. Instances of a class are allowed too (and encouraged as a best practice).
> Items in the collection are _not_ required to be [anonymous structures](https://haxe.org/manual/types-anonymous-structure.html), like `{ text: "A" }` in the example above. [Class instances](https://haxe.org/manual/types-class-instance.html) are allowed too (and encouraged as a best practice; you should prefer classes over anonymous structures).
### Selection

Expand Down Expand Up @@ -132,7 +132,7 @@ var recycler = DisplayObjectRecycler.withFunction(() -> {
});
```

> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom item renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and all other Feathers UI components.
> Developers are not required to use the [`LayoutGroupItemRenderer`](./layout-group-item-renderer.md) class. In fact, a custom item renderer may be created from any OpenFL display object, including primitives like [`openfl.display.Sprite`](https://api.openfl.org/openfl/display/Sprite.html) and [all other Feathers UI components](./ui-components.md).
Pass the [`DisplayObjectRecycler`](https://api.feathersui.com/current/feathers/utils/DisplayObjectRecycler.html) to the [`itemRendererRecycler`](https://api.feathersui.com/current/feathers/controls/ListView.html#itemRendererRecycler) property.

Expand Down
Loading

0 comments on commit 227fcb8

Please sign in to comment.