GuiGetSelectedTab: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
mNo edit summary
Line 15: Line 15:


==Example==
==Example==
This example gets the current selected tab and sets the selected tab to the next available tab.
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
-- Todo...
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, 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 check()
  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)
  else
      guiSetSelected(tabPanel,tab1) --if the "Info" tab is selected, change it to tab1("Welcome" tab)
  end
end
</syntaxhighlight>
</syntaxhighlight>



Revision as of 19:27, 6 April 2012

This function returns the currently selected tab in the specified tab panel.

Syntax

element guiGetSelectedTab ( element tabPanel )

Required Arguments

  • tabPanel: The tab panel which current tab you want to retrieve.

Returns

Returns an element of the tab if a tab was selected or nil if no tab was selected. If passed arguments were invalid or something went wrong, the function will return false.

Example

This example gets the current selected tab and sets the selected tab to the next available tab.

local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, 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 check()
   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)
   else
      guiSetSelected(tabPanel,tab1) --if the "Info" tab is selected, change it to tab1("Welcome" tab)
   end
end

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