GuiSetSelectedTab: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 16: Line 16:


==Example==
==Example==
This example changes the selected tab to the next available tab.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true) --create a tab panel which fills the whole window
local tabPanel = guiCreateTabPanel(0.1, 0.1, 0.8, 0.8, true) --create a tab panel which fills the whole window
local tab1 = guiCreateTab("Welcome",tabPanel) --create a tab for the tab panel above
local tab1 = guiCreateTab("Welcome", tabPanel) --create a tab for the tab panel above
local tab2 = guiCreateTab("Info",tabPanel)--create another tab for the tab panel at the top
local tab2 = guiCreateTab("Info", tabPanel)--create another tab for the tab panel at the top


function check()
function switchTabs()
  if(guiGetSelectedTab(tabPanel)==tab1)then --Check what tab is currently shown
    if guiGetSelectedTab(tabPanel) == tab1 then --Check what tab is currently shown
      guiSetSelected(tabPanel,tab2) --if the "Welcome" tab is selected, change it to tab2("Info" tab)
        guiSetSelectedTab(tabPanel, tab2) --if the "Welcome" tab is selected, change it to tab2("Info" tab)
  else
    else
      guiSetSelected(tabPanel,tab1) --if the "Info" tab is selected, change it to tab1("Welcome" tab)
        guiSetSelectedTab(tabPanel, tab1) --if the "Info" tab is selected, change it to tab1("Welcome" tab)
  end
    end
end
end
switchTabs()
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
[[Category:Needs Example]]
{{GUI_events}}

Latest revision as of 06:09, 7 December 2025

This function is used to change the currently selected tab in a tab panel.

Syntax

bool guiSetSelectedTab ( element tabPanel, element theTab )

Required Arguments

  • tabPanel: The tab panel which current tab you want to change.
  • theTab: The tab which will be the new active tab.

Returns

Returns true if the selected tab was changed to a new one successfully, false otherwise.

Example

This example changes the selected tab to the next available tab.

local tabPanel = guiCreateTabPanel(0.1, 0.1, 0.8, 0.8, true) --create a tab panel which fills the whole window
local tab1 = guiCreateTab("Welcome", tabPanel) --create a tab for the tab panel above
local tab2 = guiCreateTab("Info", tabPanel)--create another tab for the tab panel at the top

function switchTabs()
    if guiGetSelectedTab(tabPanel) == tab1 then --Check what tab is currently shown
        guiSetSelectedTab(tabPanel, tab2) --if the "Welcome" tab is selected, change it to tab2("Info" tab)
    else
        guiSetSelectedTab(tabPanel, tab1) --if the "Info" tab is selected, change it to tab1("Welcome" tab)
    end
end
switchTabs()

See Also

General functions

Browsers

Buttons

Checkboxes

Comboboxes

Edit Boxes

Gridlists

Memos

Progressbars

Radio Buttons

Scrollbars

Scrollpanes

Static Images

Tab Panels

Tabs

Text Labels

Windows

Input

GUI