PageView (페이지뷰) Widget Control
Widget Control (Property · Method · Event) for controlling the PageView widget from a script. For an introduction to the widget and how to use it, see PageView.
In the examples below, pageviewID is the name (ID) you assigned to the PageView widget on the canvas. In a script, access members as widgetID.member.
Widget Control summary
| Widget Control | Kind | Signature | Description |
|---|---|---|---|
add | Method | add(): number | Adds a new item at the end |
clear | Method | clear() | Removes every item |
count | Property | count (get/set, number) | Number of items (pages) to render repeatedly |
current | Property | current (get/set, number) | Index of the current item used as the binding scope |
select | Property | select (get/set, number) | Index of the selected item |
getCurrentPage | Method | getCurrentPage(): number | Returns the index of the page currently shown |
goToPage | Method | goToPage(page, duration?) | Moves to the page at the given index |
insert | Method | insert(index) | Inserts an item at the given position |
nextPage | Method | nextPage(duration?) | Moves to the next page |
onPageChanged | Event | onPageChanged = () => { ... } | Runs when the displayed page changes |
onSelected | Event | onSelected = (index) => { ... } | Runs when an item is tapped |
previousPage | Method | previousPage(duration?) | Moves to the previous page |
remove | Method | remove(index) | Removes the given item |
setState | Method | setState(index, callback) | Updates only a specific item |
Property
count
Reads or sets the number of items (pages) to render repeatedly. Set a value and the bound data list grows or shrinks to match, then redraws.
- Kind: Property (get/set)
- Type:
number(integer)
Example
pageviewID.count = 5;
const n = pageviewID.count;
current
Reads or sets the index of the current item used as the binding scope. Once set, later property writes apply to that item (row).
- Kind: Property (get/set)
- Type:
number(integer; returns-1when not set)
Example
pageviewID.current = 2;
select
Reads or sets the index of the selected item.
- Kind: Property (get/set)
- Type:
number(integer; returns-1when nothing is selected)
Example
pageviewID.select = 1;
Method
getCurrentPage
Returns the index of the page currently shown, starting at 0. If the view isn't attached to the screen yet, it returns the configured initial page value.
- Kind: Method
- Parameters: None
- Returns:
number- the current page index (0-based)
Example
const page = pageviewID.getCurrentPage();
goToPage
Moves to the page at the given index.
- Kind: Method
- Parameters:
page(number) - index of the page to move to (0-based)duration(number, optional, default300) - scroll animation duration in milliseconds.0or less moves immediately, with no animation.
- Returns: None
Example
pageviewID.goToPage(2, 300);
nextPage
Animates to the next page.
- Kind: Method
- Parameters:
duration(number, optional, default300) - scroll animation duration in milliseconds - Returns: None
Example
pageviewID.nextPage(300);
previousPage
Animates to the previous page.
- Kind: Method
- Parameters:
duration(number, optional, default300) - scroll animation duration in milliseconds - Returns: None
Example
pageviewID.previousPage(300);
add
Adds a new empty item at the end and redraws.
- Kind: Method
- Parameters: None
- Returns:
number- index of the newly added item
Example
const i = pageviewID.add();
insert
Inserts a new empty item at the given index and redraws.
- Kind: Method
- Parameters:
index(number) - position to insert at - Returns: None
Example
pageviewID.insert(0);
remove
Removes the item at the given index and redraws. Does nothing if the index is out of range.
- Kind: Method
- Parameters:
index(number) - index of the item to remove - Returns: None
Example
pageviewID.remove(0);
clear
Removes every item and redraws.
- Kind: Method
- Parameters: None
- Returns: None
Example
pageviewID.clear();
setState
Runs the callback with the binding scope set to the given item, then redraws only that item. Use it to update the bound properties of a specific item.
- Kind: Method
- Parameters:
index(number) - index of the item to updatecallback(function) - callback to run whileindexis the active item
- Returns: None
Example
pageviewID.setState(0, () => { /* update the bound properties of item 0 */ });
Event
onPageChanged
Runs when the displayed page changes, either by a swipe or by a script move.
- Kind: Event
- Handler: a callback function that takes no arguments
- Returns: None
Example
pageviewID.onPageChanged = () => {
// code to run when the page changes
};
onSelected
Runs when the user taps an item.
- Kind: Event
- Handler: a callback function that receives
index, the index of the tapped item - Returns: None
Example
pageviewID.onSelected = (index) => {
// handle the selected index
};
Common Widget Control (all widgets)
Every widget can use name-based common Widget Control (Method) such as setProperty / getProperty / setStyleProperty. See the common reference doc (to be written).