GuiDeleteTab: Difference between revisions

From Multi Theft Auto: Wiki
Jump to navigation Jump to search
No edit summary
m (Added OOP Method Information)
 
(8 intermediate revisions by 5 users not shown)
Line 1: Line 1:
{{Needs_checking|This function doesnt actually work. --[[User:Talidan2|Talidan2]] 13:30, 15 August 2007 (CDT)}}
__NOTOC__  
__NOTOC__  
{{Client function}}
{{Client function}}
This function allows for deletion of a tab from a tab panel
This function deletes a tab from a tab panel.


==Syntax==  
==Syntax==  
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
bool guiDeleteTab ( element tabToDelete )
bool guiDeleteTab ( element tabToDelete, element tabPanel )
</syntaxhighlight>  
</syntaxhighlight>  
 
{{OOP||[[Element/GUI/Tab|GuiTab]]:delete}}
===Required Arguments===  
===Required Arguments===  
*'''tabToDelete:''' This is an element representing the tab that you want to delete.
*'''tabToDelete:''' This is an element representing the tab that you want to delete.
*'''tabPanel:''' This is the [[guiCreateTabPanel|tab panel]] parent that the tab is attached to.


===Returns===
===Returns===
Line 19: Line 19:
<syntaxhighlight lang="lua">
<syntaxhighlight lang="lua">
function deleteTabOnClick ()
function deleteTabOnClick ()
if ( getKeyState ( "lctrl" ) == true ) then --if he's holding down left control
if ( getKeyState ( "lctrl" ) == true ) and ( getElementType( source ) == "gui-tab" ) then   -- if the user is holding down left control
guiDeleteTab ( source )--delete the tab. The function wont work anyway for other types of elements so no check is required.
guiDeleteTab ( source, getElementParent(source) )                -- delete the tab. No need to check if it was actually a tab that was clicked, as this function doesn't work on other controls anyway
end
end
end
end
addEventHandler ( "onClientClick", getRootElement(), deleteTabOnClick  )--add an event handler for this
addEventHandler ( "onClientGUIClick", getRootElement(), deleteTabOnClick  )   -- add an event handler for clicks
</syntaxhighlight>
</syntaxhighlight>


==See Also==
==See Also==
{{GUI functions}}
{{GUI functions}}
{{GUI_events}}

Latest revision as of 11:51, 7 August 2019

This function deletes a tab from a tab panel.

Syntax

bool guiDeleteTab ( element tabToDelete, element tabPanel )

OOP Syntax Help! I don't understand this!

Method: GuiTab:delete(...)


Required Arguments

  • tabToDelete: This is an element representing the tab that you want to delete.
  • tabPanel: This is the tab panel parent that the tab is attached to.

Returns

Returns true the tab was successfully deleted, false otherwise.

Example

This example removes a tab panel if a user LeftCtrl+Clicks a tab panel.

function deleteTabOnClick ()
	if ( getKeyState ( "lctrl" ) == true ) and ( getElementType( source ) == "gui-tab" ) then    -- if the user is holding down left control
		guiDeleteTab ( source, getElementParent(source) )                -- delete the tab. No need to check if it was actually a tab that was clicked, as this function doesn't work on other controls anyway
	end
end
addEventHandler ( "onClientGUIClick", getRootElement(), deleteTabOnClick  )    -- add an event handler for clicks

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