Skip to main content

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.

info

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 ControlKindSignatureDescription
addMethodadd(): numberAdds a new item at the end
clearMethodclear()Removes every item
countPropertycount (get/set, number)Number of items (pages) to render repeatedly
currentPropertycurrent (get/set, number)Index of the current item used as the binding scope
selectPropertyselect (get/set, number)Index of the selected item
getCurrentPageMethodgetCurrentPage(): numberReturns the index of the page currently shown
goToPageMethodgoToPage(page, duration?)Moves to the page at the given index
insertMethodinsert(index)Inserts an item at the given position
nextPageMethodnextPage(duration?)Moves to the next page
onPageChangedEventonPageChanged = () => { ... }Runs when the displayed page changes
onSelectedEventonSelected = (index) => { ... }Runs when an item is tapped
previousPageMethodpreviousPage(duration?)Moves to the previous page
removeMethodremove(index)Removes the given item
setStateMethodsetState(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 -1 when not set)

Example

pageviewID.current = 2;

select

Reads or sets the index of the selected item.

  • Kind: Property (get/set)
  • Type: number (integer; returns -1 when 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, default 300) - scroll animation duration in milliseconds. 0 or 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, default 300) - scroll animation duration in milliseconds
  • Returns: None

Example

pageviewID.nextPage(300);

previousPage

Animates to the previous page.

  • Kind: Method
  • Parameters: duration (number, optional, default 300) - 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 update
    • callback (function) - callback to run while index is 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)

note

Every widget can use name-based common Widget Control (Method) such as setProperty / getProperty / setStyleProperty. See the common reference doc (to be written).