<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/OnDgsPropertyChange?action=history&amp;feed=atom</id>
	<title>OnDgsPropertyChange - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/OnDgsPropertyChange?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnDgsPropertyChange&amp;action=history"/>
	<updated>2026-05-08T15:46:53Z</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=OnDgsPropertyChange&amp;diff=82193&amp;oldid=prev</id>
		<title>Mohab: Created page with &quot;__NOTOC__ {{Client event}} This event is triggered when a monitored property of a dgs element changes via dgsSetProperty. The property must be added to the listener using dgsAddPropertyListener for this event to fire.  {{Note|This event only fires for properties that have been explicitly added as listeners using dgsAddPropertyListener}} {{Note|The event only triggers when using dgsSetProperty, not element-specific functions like dgsSetText}} {{Tip|Thi...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=OnDgsPropertyChange&amp;diff=82193&amp;oldid=prev"/>
		<updated>2025-07-10T02:44:35Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__ {{Client event}} This event is triggered when a monitored property of a dgs element changes via &lt;a href=&quot;/wiki/DgsSetProperty&quot; title=&quot;DgsSetProperty&quot;&gt;dgsSetProperty&lt;/a&gt;. The property must be added to the listener using &lt;a href=&quot;/wiki/DgsAddPropertyListener&quot; title=&quot;DgsAddPropertyListener&quot;&gt;dgsAddPropertyListener&lt;/a&gt; for this event to fire.  {{Note|This event only fires for properties that have been explicitly added as listeners using &lt;a href=&quot;/wiki/DgsAddPropertyListener&quot; title=&quot;DgsAddPropertyListener&quot;&gt;dgsAddPropertyListener&lt;/a&gt;}} {{Note|The event only triggers when using &lt;a href=&quot;/wiki/DgsSetProperty&quot; title=&quot;DgsSetProperty&quot;&gt;dgsSetProperty&lt;/a&gt;, not element-specific functions like &lt;a href=&quot;/wiki/DgsSetText&quot; title=&quot;DgsSetText&quot;&gt;dgsSetText&lt;/a&gt;}} {{Tip|Thi...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__&lt;br /&gt;
{{Client event}}&lt;br /&gt;
This event is triggered when a monitored property of a dgs element changes via [[dgsSetProperty]]. The property must be added to the listener using [[dgsAddPropertyListener]] for this event to fire.&lt;br /&gt;
&lt;br /&gt;
{{Note|This event only fires for properties that have been explicitly added as listeners using [[dgsAddPropertyListener]]}}&lt;br /&gt;
{{Note|The event only triggers when using [[dgsSetProperty]], not element-specific functions like [[dgsSetText]]}}&lt;br /&gt;
{{Tip|This event does NOT fire for user input changes (like typing in edit boxes). For monitoring user text input, use [[onDgsTextChange]] instead}}&lt;br /&gt;
{{Note|The event will not fire if the new value is the same as the old value}}&lt;br /&gt;
{{Tip|This event is designed for programmatic property changes, not user interactions}}&lt;br /&gt;
&lt;br /&gt;
==Parameters==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;string propertyName, mixed newValue, mixed oldValue&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
*'''propertyName:''' the name of the property that changed&lt;br /&gt;
*'''newValue:''' the new value that was set&lt;br /&gt;
*'''oldValue:''' the previous value before the change&lt;br /&gt;
&lt;br /&gt;
==Source==&lt;br /&gt;
The source is the dgs element whose property was changed.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
This example shows how to monitor window position changes:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local window = DGS:dgsCreateWindow(200, 200, 400, 300, &amp;quot;Property Monitor&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
-- Add listener for position changes&lt;br /&gt;
DGS:dgsAddPropertyListener(window, &amp;quot;absPos&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Handle property changes&lt;br /&gt;
function handlePropertyChange(propertyName, newValue, oldValue)&lt;br /&gt;
    if propertyName == &amp;quot;absPos&amp;quot; then&lt;br /&gt;
        outputChatBox(&amp;quot;Window moved from &amp;quot; .. oldValue[1] .. &amp;quot;,&amp;quot; .. oldValue[2] ..&lt;br /&gt;
                     &amp;quot; to &amp;quot; .. newValue[1] .. &amp;quot;,&amp;quot; .. newValue[2])&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onDgsPropertyChange&amp;quot;, window, handlePropertyChange)&lt;br /&gt;
&lt;br /&gt;
-- Test the listener&lt;br /&gt;
setTimer(function()&lt;br /&gt;
    DGS:dgsSetProperty(window, &amp;quot;absPos&amp;quot;, {300, 250})&lt;br /&gt;
end, 2000, 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example demonstrates onDgsPropertyChange with programmatic text updates:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local window = DGS:dgsCreateWindow(300, 200, 320, 320, &amp;quot;Property Change Demo&amp;quot;, false)&lt;br /&gt;
local nameEdit = DGS:dgsCreateEdit(20, 50, 280, 30, &amp;quot;&amp;quot;, false, window)&lt;br /&gt;
local emailEdit = DGS:dgsCreateEdit(20, 100, 280, 30, &amp;quot;&amp;quot;, false, window)&lt;br /&gt;
local submitBtn = DGS:dgsCreateButton(20, 150, 280, 40, &amp;quot;Submit (Disabled)&amp;quot;, false, window)&lt;br /&gt;
local statusLabel = DGS:dgsCreateLabel(20, 200, 280, 40, &amp;quot;Click buttons to set text&amp;quot;, false, window)&lt;br /&gt;
local setNameBtn = DGS:dgsCreateButton(20, 250, 135, 30, &amp;quot;Set Name&amp;quot;, false, window)&lt;br /&gt;
local setEmailBtn = DGS:dgsCreateButton(165, 250, 135, 30, &amp;quot;Set Email&amp;quot;, false, window)&lt;br /&gt;
&lt;br /&gt;
DGS:dgsCreateLabel(20, 30, 100, 20, &amp;quot;Name:&amp;quot;, false, window)&lt;br /&gt;
DGS:dgsCreateLabel(20, 80, 100, 20, &amp;quot;Email:&amp;quot;, false, window)&lt;br /&gt;
&lt;br /&gt;
-- Monitor text property changes&lt;br /&gt;
DGS:dgsAddPropertyListener(nameEdit, &amp;quot;text&amp;quot;)&lt;br /&gt;
DGS:dgsAddPropertyListener(emailEdit, &amp;quot;text&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
function validateForm()&lt;br /&gt;
    local name = DGS:dgsGetProperty(nameEdit, &amp;quot;text&amp;quot;)&lt;br /&gt;
    local email = DGS:dgsGetProperty(emailEdit, &amp;quot;text&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
    local isValid = (name and name ~= &amp;quot;&amp;quot; and email and email ~= &amp;quot;&amp;quot; and string.find(email, &amp;quot;@&amp;quot;))&lt;br /&gt;
&lt;br /&gt;
    DGS:dgsSetProperty(submitBtn, &amp;quot;enabled&amp;quot;, isValid)&lt;br /&gt;
    if isValid then&lt;br /&gt;
        DGS:dgsSetProperty(submitBtn, &amp;quot;text&amp;quot;, &amp;quot;Submit (Ready!)&amp;quot;)&lt;br /&gt;
        DGS:dgsSetProperty(statusLabel, &amp;quot;text&amp;quot;, &amp;quot;Form is valid!&amp;quot;)&lt;br /&gt;
        DGS:dgsSetProperty(statusLabel, &amp;quot;textColor&amp;quot;, tocolor(0, 255, 0, 255))&lt;br /&gt;
    else&lt;br /&gt;
        DGS:dgsSetProperty(submitBtn, &amp;quot;text&amp;quot;, &amp;quot;Submit (Disabled)&amp;quot;)&lt;br /&gt;
        DGS:dgsSetProperty(statusLabel, &amp;quot;text&amp;quot;, &amp;quot;Fill both fields&amp;quot;)&lt;br /&gt;
        DGS:dgsSetProperty(statusLabel, &amp;quot;textColor&amp;quot;, tocolor(255, 0, 0, 255))&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
function handlePropertyChange(propertyName, newValue, oldValue)&lt;br /&gt;
    outputChatBox(&amp;quot;Property '&amp;quot; .. propertyName .. &amp;quot;' changed to: &amp;quot; .. tostring(newValue))&lt;br /&gt;
    validateForm()&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onDgsPropertyChange&amp;quot;, nameEdit, handlePropertyChange)&lt;br /&gt;
addEventHandler(&amp;quot;onDgsPropertyChange&amp;quot;, emailEdit, handlePropertyChange)&lt;br /&gt;
&lt;br /&gt;
-- Button handlers to trigger property changes&lt;br /&gt;
addEventHandler(&amp;quot;onDgsMouseClick&amp;quot;, setNameBtn, function()&lt;br /&gt;
    DGS:dgsSetProperty(nameEdit, &amp;quot;text&amp;quot;, &amp;quot;John Doe&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onDgsMouseClick&amp;quot;, setEmailBtn, function()&lt;br /&gt;
    DGS:dgsSetProperty(emailEdit, &amp;quot;text&amp;quot;, &amp;quot;john@example.com&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
validateForm()&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows onDgsPropertyChange with button properties:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local button = DGS:dgsCreateButton(100, 100, 200, 50, &amp;quot;Click Me&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
-- Monitor button properties&lt;br /&gt;
DGS:dgsAddPropertyListener(button, {&amp;quot;alpha&amp;quot;, &amp;quot;enabled&amp;quot;})&lt;br /&gt;
&lt;br /&gt;
function handleButtonChange(propertyName, newValue, oldValue)&lt;br /&gt;
    outputChatBox(&amp;quot;Button property '&amp;quot; .. propertyName .. &amp;quot;' changed from &amp;quot; ..&lt;br /&gt;
                 tostring(oldValue) .. &amp;quot; to &amp;quot; .. tostring(newValue))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onDgsPropertyChange&amp;quot;, button, handleButtonChange)&lt;br /&gt;
&lt;br /&gt;
-- Test the property changes&lt;br /&gt;
setTimer(function()&lt;br /&gt;
    DGS:dgsSetProperty(button, &amp;quot;alpha&amp;quot;, 128)&lt;br /&gt;
    DGS:dgsSetProperty(button, &amp;quot;enabled&amp;quot;, false)&lt;br /&gt;
end, 2000, 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
This example shows monitoring multiple properties:&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
DGS = exports.dgs&lt;br /&gt;
local button = DGS:dgsCreateButton(100, 100, 200, 50, &amp;quot;Monitor Me&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
-- Monitor multiple properties&lt;br /&gt;
DGS:dgsAddPropertyListener(button, {&amp;quot;text&amp;quot;, &amp;quot;alpha&amp;quot;, &amp;quot;visible&amp;quot;})&lt;br /&gt;
&lt;br /&gt;
function handleButtonChange(propertyName, newValue, oldValue)&lt;br /&gt;
    outputChatBox(&amp;quot;Property '&amp;quot; .. propertyName .. &amp;quot;' changed from &amp;quot; ..&lt;br /&gt;
                 tostring(oldValue) .. &amp;quot; to &amp;quot; .. tostring(newValue))&lt;br /&gt;
end&lt;br /&gt;
addEventHandler(&amp;quot;onDgsPropertyChange&amp;quot;, button, handleButtonChange)&lt;br /&gt;
&lt;br /&gt;
-- Test changes&lt;br /&gt;
setTimer(function()&lt;br /&gt;
    DGS:dgsSetProperty(button, &amp;quot;text&amp;quot;, &amp;quot;Changed!&amp;quot;)&lt;br /&gt;
    DGS:dgsSetProperty(button, &amp;quot;alpha&amp;quot;, 128)&lt;br /&gt;
end, 1000, 1)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
{{Tip|Use [[dgsRemovePropertyListener]] to stop monitoring properties when no longer needed}}&lt;br /&gt;
&lt;br /&gt;
'''Author:''' [[User:Mohab|Mohab]]&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
===DGS events===&lt;br /&gt;
{{DGSEVENTS}}&lt;br /&gt;
&lt;br /&gt;
===DGS functions===&lt;br /&gt;
*[[dgsAddPropertyListener]]&lt;br /&gt;
*[[dgsRemovePropertyListener]]&lt;br /&gt;
*[[dgsGetListenedProperties]]&lt;br /&gt;
*[[dgsSetProperty]]&lt;br /&gt;
*[[dgsGetProperty]]&lt;br /&gt;
&lt;br /&gt;
===Client event functions===&lt;br /&gt;
{{Client_event_functions}}&lt;/div&gt;</summary>
		<author><name>Mohab</name></author>
	</entry>
</feed>