pyui.set_on_change_handler - pytha-3d-cad/pytha-lua-api GitHub Wiki
Sets the on_change handler for controls that support it. The change event is usually invoked when the user changes the (text-) content of a control. The handler is not invoked if the content is changed by the lua script.
pyui.set_on_change_handler(control, func)
control:set_on_change_handler(func)
Parameters
| Type | Description | |
|---|---|---|
control |
control_handle |
A control handle returned by one of the pyui.create_xxx control creation functions |
func |
function |
A lua function that is invoked for every change event |
Return value
| Type | Description |
|---|---|
control_handle |
The control handle is returned again |
Note:
This handler is specific to the current modal environment / dialog and can only be set within a dialog.
The parameters to the on_change handler differ slightly depending on the control on which it is used
function on_change_handler(text [, index])
| Type | Description | |
|---|---|---|
text |
string |
The new content text |
index |
integer |
The newly selected item index if applicable |
A useful pattern is to write the handler function inline
local text_box = pyui.create_text_box(2)
text_box:set_on_change_handler(function(text)
-- do something with the new content: text
end)
Version requirements
This function is available in V26 and above.
See also
Control Gallery, set_on_click_handler, create_text_box, create_combo_box, create_drop_list