OnClientGUITabSwitched: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
mNo edit summary |
||
(4 intermediate revisions by 4 users not shown) | |||
Line 2: | Line 2: | ||
__NOTOC__ | __NOTOC__ | ||
This event is triggered each time the user switch from GUI tab. | This event is triggered each time the user switch from GUI tab. | ||
When adding the event handler on the tab panel, propagate must be true. | |||
==Parameters== | ==Parameters== | ||
Line 7: | Line 9: | ||
element theElement | element theElement | ||
</syntaxhighlight> | </syntaxhighlight> | ||
* '''theElement''': | * '''theElement''': the [[Element/GUI/Tab|tab]] which was selected. | ||
==Source== | ==Source== | ||
The [[event system#Event source|source]] of this event is the | The [[event system#Event source|source]] of this event is the tab. | ||
==Example== | ==Example== | ||
Line 30: | Line 32: | ||
<syntaxhighlight lang="lua"> | <syntaxhighlight lang="lua"> | ||
function OnChange( selectedTab ) | function OnChange(selectedTab) | ||
-- If there is a selected tab. | -- If there is a selected tab. | ||
if selectedTab ~= nil then | if selectedTab ~= nil then | ||
outputChatBox( "You've changed your active tab." ) | outputChatBox( "You've changed your active tab." ) | ||
end | end | ||
end | end | ||
addEventHandler("onClientGUITabSwitched", | addEventHandler("onClientGUITabSwitched", root, OnChange) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
==See Also== | ==See Also== | ||
{{GUI_events}} | {{GUI_events}} | ||
===Client event functions=== | ===Client event functions=== | ||
{{Client_event_functions}} | {{Client_event_functions}} |
Latest revision as of 17:42, 16 June 2021
This event is triggered each time the user switch from GUI tab.
When adding the event handler on the tab panel, propagate must be true.
Parameters
element theElement
- theElement: the tab which was selected.
Source
The source of this event is the tab.
Example
This example creates a window with a tabpanel with two tabs. Every time a user changes tabpage a notification will be shown.
First we'll 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 let's add the event handler.
function OnChange(selectedTab) -- If there is a selected tab. if selectedTab ~= nil then outputChatBox( "You've changed your active tab." ) end end addEventHandler("onClientGUITabSwitched", root, OnChange)
See Also
Input
GUI
- onClientGUIAccepted
- onClientGUIBlur
- onClientGUIChanged
- onClientGUIClick
- onClientGUIComboBoxAccepted
- onClientGUIDoubleClick
- onClientGUIFocus
- onClientGUIMouseDown
- onClientGUIMouseUp
- onClientGUIMove
- onClientGUIScroll
- onClientGUISize
- onClientGUITabSwitched
- onClientMouseEnter
- onClientMouseLeave
- onClientMouseMove
- onClientMouseWheel
Client event functions
- triggerLatentServerEvent
- triggerServerEvent
- Shared
- addEvent
- addEventHandler
- cancelEvent
- cancelLatentEvent
- getEventHandlers
- getLatentEventHandles
- getLatentEventStatus
- removeEventHandler
- triggerEvent
- wasEventCancelled