<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/GUI_Classes/Button:RemoveOnTextChanged?action=history&amp;feed=atom</id>
	<title>GUI Classes/Button:RemoveOnTextChanged - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/GUI_Classes/Button:RemoveOnTextChanged?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GUI_Classes/Button:RemoveOnTextChanged&amp;action=history"/>
	<updated>2026-05-16T15:32:12Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GUI_Classes/Button:RemoveOnTextChanged&amp;diff=44508&amp;oldid=prev</id>
		<title>Ccw: /* Example */</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GUI_Classes/Button:RemoveOnTextChanged&amp;diff=44508&amp;oldid=prev"/>
		<updated>2015-02-11T16:35:21Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Example&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 16:35, 11 February 2015&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l19&quot;&gt;Line 19:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 19:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This example creates a button. The button has two functions attached to it, one is triggered when user clicks the button (to change text on the button) and the other one is triggered when the text has changed then the function is detached and no longer triggered.&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;This example creates a button. The button has two functions attached to it, one is triggered when user clicks the button (to change text on the button) and the other one is triggered when the text has changed then the function is detached and no longer triggered.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;−&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, getResourceRootElement( &lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;getThisResource( ) &lt;/del&gt;),&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot; data-marker=&quot;+&quot;&gt;&lt;/td&gt;&lt;td style=&quot;color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, getResourceRootElement(),&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     function( )&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;     function( )&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         --create a button object&lt;/div&gt;&lt;/td&gt;&lt;td class=&quot;diff-marker&quot;&gt;&lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #202122; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;         --create a button object&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;

&lt;!-- diff cache key wiki-wiki_dev_:diff::1.12:old-18488:rev-44508 --&gt;
&lt;/table&gt;</summary>
		<author><name>Ccw</name></author>
	</entry>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GUI_Classes/Button:RemoveOnTextChanged&amp;diff=18488&amp;oldid=prev</id>
		<title>50p: New page: &lt;pageclass class=&quot;client&quot; subcaption=&quot;GUI Class method&quot;&gt;&lt;/pageclass&gt; __NOTOC__   You can use this method to remove a function that was attached to the sham event with [[GUI_Classes/Button:...</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GUI_Classes/Button:RemoveOnTextChanged&amp;diff=18488&amp;oldid=prev"/>
		<updated>2009-03-01T14:28:42Z</updated>

		<summary type="html">&lt;p&gt;New page: &amp;lt;pageclass class=&amp;quot;client&amp;quot; subcaption=&amp;quot;GUI Class method&amp;quot;&amp;gt;&amp;lt;/pageclass&amp;gt; __NOTOC__   You can use this method to remove a function that was attached to the sham event with [[GUI_Classes/Button:...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;pageclass class=&amp;quot;client&amp;quot; subcaption=&amp;quot;GUI Class method&amp;quot;&amp;gt;&amp;lt;/pageclass&amp;gt;&lt;br /&gt;
__NOTOC__ &lt;br /&gt;
&lt;br /&gt;
You can use this method to remove a function that was attached to the sham event with [[GUI_Classes/Button:AddOnTextChanged|object:AddOnTextChanged]]. The function you pass to this method will be removed from the list and will no longer be triggered when text changes.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool Button:RemoveOnTextChanged ( function func )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''func:''' the function you want to remove from the list of functions triggered when text changes&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
*'''true''' if function was removed successfully &lt;br /&gt;
*'''false''' otherwise&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example creates a button. The button has two functions attached to it, one is triggered when user clicks the button (to change text on the button) and the other one is triggered when the text has changed then the function is detached and no longer triggered.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
addEventHandler ( &amp;quot;onClientResourceStart&amp;quot;, getResourceRootElement( getThisResource( ) ),&lt;br /&gt;
    function( )&lt;br /&gt;
        --create a button object&lt;br /&gt;
        local button = Button:Create( 0.7, 0.1, 0.2, 0.1, &amp;quot;Hello&amp;quot;, true );&lt;br /&gt;
&lt;br /&gt;
        -- and attach a function to the button which changes its text&lt;br /&gt;
        button:AddOnClick( changeMyText );&lt;br /&gt;
&lt;br /&gt;
        -- add myTextHasChanged to the list of triggered functions when text changes&lt;br /&gt;
        button:AddOnTextChanged( myTextHasChanged );&lt;br /&gt;
    end&lt;br /&gt;
)&lt;br /&gt;
&lt;br /&gt;
--setup a function to change the text&lt;br /&gt;
function changeMyText ( )&lt;br /&gt;
    local text = button:Text( ) --get the text from the button&lt;br /&gt;
    if text == &amp;quot;Hello&amp;quot; then&lt;br /&gt;
        -- if text of button was &amp;quot;Hello&amp;quot;, change it to &amp;quot;World!&amp;quot;&lt;br /&gt;
        button:Text( &amp;quot;World!&amp;quot; );&lt;br /&gt;
        button:Enabled( false );&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function myTextHasChanged( btn, oldText, newText  )&lt;br /&gt;
    -- if new text is &amp;quot;World!&amp;quot; then set a timer which will change it back to old text (in this case &amp;quot;Hello&amp;quot;),&lt;br /&gt;
    -- enable the button and remove this function from the stack&lt;br /&gt;
    if newText == &amp;quot;World!&amp;quot; then&lt;br /&gt;
        setTimer( btn:Text, 2500, 1, oldTex );&lt;br /&gt;
        setTimer( btn:Enabled, 2500, 1, true );&lt;br /&gt;
    end&lt;br /&gt;
    btn:RemoveOnTextChanged( myTextHasChanged );&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
[[GUI_Classes|Back to GUI Classes page]]&lt;br /&gt;
{{GUI_Classes_allfunctions}}&lt;/div&gt;</summary>
		<author><name>50p</name></author>
	</entry>
</feed>