Aeon Server Addon Form Elements and Basic Events

In order to provide greater capabilities to addon developers, we've exposed some basic events for some of our form elements. These events will allow you to respond to changes in the form element's values.

Test Addon

The following demo addon will help to provide additional clarification.

  1. Download the demo addon from the link above.
  2. Extract the FormElementEventDemo folder.
  3. Place the extracted folder in the C:\Users\(your username)\Documents\Aeon\Addons folder.
  4. If the Aeon client is open, close it. Then re-open the client.
  5. The Form Element Event Demo addon will appear as a tab.
  6. To disable this addon, click the Manage tab then click Addons.

More Information

These changes apply to the following form elements. These elements are described further on the Form Elements page in the Atlas Addons space.

  • CheckEdit
  • ComboBoxEdit
  • MemoEdit
  • RadioGroup
  • TextEdit
  • ListBox

The events that we are making available on these elements are the EditValueChanged and EditValueChanging events, with the exception of ListBox which has the SelectedValueChanged event instead. You register for these events using the functions AddEditValueChangedEventHandler(), AddEditValueChangingEventHandler(), and AddSelectedValueChangedEventHandler() respectively, passing in a function to handle the event when it's raised. Traditionally, the event handler will accept two parameters; the first is the object that raised the event, and the second is the event arguments object. Both of these parameters are optional.

For example, say I have a CheckEdit form element called myCheckEdit and a function called logChanges that logs changes made to form elements. I can register the logChanges function as an event handler for myCheckEdit's EditValueChanged event with the following statement:

myCheckEdit:AddEditValueChangedEventHandler(logChanges);


The logChanges function could be implemented as such:

function logChanges(sender, args)
-- The sender parameter is the object that raised the event. In this case, that's 
-- the myCheckEdit form element. The args parameter is not useful here and could 
-- be removed.
LogDebug("Value of control " .. sender.Name .. " changed to " .. sender.Value);
end 

The event arguments for the EditValueChanged event don't contain any useful information and can be left out of the function declaration. The sender parameter can also be omitted if you have no use for it.


In contrast, the EditValueChanging event provides an event argument object with the following fields:

  • OldValue: The form element's original value
  • NewValue: The value the form element is being set to
  • Cancel: A boolean value that allows you to cancel this change.

Let's say we have a number field that we never want to decrease in value. The event handler for that might look like this:

function numberChanges(sender, args)
 if args.OldValue > args.NewValue then
  args.Cancel = true;
 end;
end

Lastly, the ListBox form element doesn't have the EditValueChanged or EditValueChanging events, but instead has a SelectedValueChanged event that indicates when there is a change in which elements of the list box are selected.