Difference between revisions of "Lua:Class:PageControl"
Jump to navigation
Jump to search
(Major overhaul of the post.) |
m (→Returns) |
||
| Line 51: | Line 51: | ||
===Returns=== | ===Returns=== | ||
| − | [[Lua:Class: | + | [[Lua:Class:PageControl|PageControl]] — The created page control object. |
== Properties == | == Properties == | ||
Latest revision as of 20:42, 26 June 2026
The Pagecontrol class represents a control that can hold multiple pages.
Each page is represented by a TabSheet. A Pagecontrol can be created with createPageControl.
Inheritance[edit]
| Class | Inherits From | Description |
|---|---|---|
| Pagecontrol | WinControl | Represents a multi-page tab control. |
| WinControl | Control | Base class for controls that can receive focus and contain child controls. |
| Control | Component | Base class for visible GUI controls. |
| Component | Object | Base class for components. |
| Object | None | Base class for Lua-exposed objects. |
Creation[edit]
Creates a Pagecontrol object that belongs to the given owner.
Function Parameters[edit]
| Parameter | Type | Description |
|---|---|---|
| owner | WinControl | The owner of the page control. |
Returns[edit]
PageControl — The created page control object.
Properties[edit]
| Property | Type | Description |
|---|---|---|
| ShowTabs | Boolean | Determines whether the tabs are shown. |
| TabIndex | Integer | Gets or sets the currently selected tab index. |
| ActivePage | TabSheet | Returns the currently active tab sheet. |
| PageCount | Integer | Returns the number of pages. |
| Page[index] | TabSheet | Returns the page at the specified index. |
Methods[edit]
| Method | Return Type | Description |
|---|---|---|
| addTab() | TabSheet | Creates a new TabSheet and adds it to the page control. |
| tabRect(index) | Rect | Returns a Rect table describing the position of the specified tab. |
Rect Table[edit]
tabRect(index) returns a Rect table.
| Field | Type | Description |
|---|---|---|
| Left | Integer | The left coordinate of the tab rectangle. |
| Top | Integer | The top coordinate of the tab rectangle. |
| Right | Integer | The right coordinate of the tab rectangle. |
| Bottom | Integer | The bottom coordinate of the tab rectangle. |
Examples[edit]
Create a Pagecontrol[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.Left = 10
5 pageControl.Top = 10
6 pageControl.Width = 300
7 pageControl.Height = 200
8
9 form.show()
Add pages[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 local firstPage = pageControl.addTab()
5 firstPage.Caption = "General"
6
7 local secondPage = pageControl.addTab()
8 secondPage.Caption = "Advanced"
9
10 form.show()
Select a tab by index[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.addTab().Caption = "First"
5 pageControl.addTab().Caption = "Second"
6
7 pageControl.TabIndex = 1
8
9 form.show()
Read the active page[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.addTab().Caption = "First"
5 pageControl.addTab().Caption = "Second"
6
7 pageControl.TabIndex = 0
8 local activePage = pageControl.ActivePage
9
10 print(activePage.Caption)
11
12 form.show()
Hide the tabs[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.ShowTabs = false
5
6 pageControl.addTab().Caption = "Hidden Tab"
7
8 form.show()
Enumerate pages[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.addTab().Caption = "Page A"
5 pageControl.addTab().Caption = "Page B"
6
7 for i = 0, pageControl.PageCount - 1 do
8 local page = pageControl.Page[i]
9
10 print(i .. ": " .. tostring(page.Caption))
11 end
12
13 form.show()
Add controls to a TabSheet[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 local page = pageControl.addTab()
5 page.Caption = "Settings"
6
7 local label = createLabel(page)
8 label.Caption = "This label belongs to the tab sheet"
9 label.Left = 10
10 label.Top = 10
11
12 form.show()
Get a tab rectangle[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.addTab().Caption = "General"
5
6 local rect = pageControl.tabRect(0)
7
8 print("Left: " .. tostring(rect.Left))
9 print("Top: " .. tostring(rect.Top))
10 print("Right: " .. tostring(rect.Right))
11 print("Bottom: " .. tostring(rect.Bottom))
12
13 form.show()
Switch to the next tab[edit]
1 local form = createForm(false)
2 local pageControl = createPageControl(form)
3
4 pageControl.addTab().Caption = "First"
5 pageControl.addTab().Caption = "Second"
6
7 if pageControl.PageCount > 0 then
8 pageControl.TabIndex = (pageControl.TabIndex + 1) % pageControl.PageCount
9 end
10
11 form.show()