OnClientGUITabSwitched: Difference between revisions
Jump to navigation
Jump to search
Line 10: | Line 10: | ||
==Example== | ==Example== | ||
This example creates a window with a tabpanel with two tabs. Every time a user changes tabpage a notification will be shown. | |||
First well create the window. Then add a tabpanel and couple tabs with some labels in them. Qoute: [[GuiCreateWindow#Example]] | |||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
-- | local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar. | ||
local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window | |||
local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel' | |||
local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel' | |||
-- adds a label (text) to each tab | |||
guiCreateLabel( 0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap ) | |||
guiCreateLabel( 0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp ) | |||
</syntaxhighlight> | |||
Now lets add the event handler. | |||
<syntaxhighlight lang="lua"> | |||
function OnChange( selectedTab ) | |||
-- If there is a selected tab. | |||
if selectedTab ~= nil then | |||
outPutChatBox( "You've changed your active tab.", getLocalPlayer( ) ) | |||
end | |||
end | |||
addEventHandler("onClientGUITabSwitched", getRootElement( ), OnChange) | |||
</syntaxhighlight> | </syntaxhighlight> | ||
Revision as of 14:02, 20 August 2009
This event is triggered each time the user switch from GUI tab.
Parameters
element theElement
- theElement: The element which was selected.
Example
This example creates a window with a tabpanel with two tabs. Every time a user changes tabpage a notification will be shown.
First well create the window. Then add a tabpanel and couple tabs with some labels in them. Qoute: GuiCreateWindow#Example
local myWindow = guiCreateWindow ( 0, 0, 0.5, 0.4, "Information", true ) -- create a window which has "Information" in the title bar. local tabPanel = guiCreateTabPanel ( 0, 0.1, 1, 1, true, myWindow ) -- create a tab panel which fills the whole window local tabMap = guiCreateTab( "Map Information", tabPanel ) -- create a tab named "Map Information" on 'tabPanel' local tabHelp = guiCreateTab( "Help", tabPanel ) -- create another tab named "Help" on 'tabPanel' -- adds a label (text) to each tab guiCreateLabel( 0.02, 0.04, 0.94, 0.2, "This is information about the current map", true, tabMap ) guiCreateLabel( 0.02, 0.04, 0.94, 0.92, "This is help text.", true, tabHelp )
Now lets add the event handler.
function OnChange( selectedTab ) -- If there is a selected tab. if selectedTab ~= nil then outPutChatBox( "You've changed your active tab.", getLocalPlayer( ) ) end end addEventHandler("onClientGUITabSwitched", getRootElement( ), OnChange)
See Also
GUI events
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel