Function run upon Button Pressed

The code below is a simple example file i put together for the sake of finding a solution.
I want the list of names to be updated upon the user clicking Apply or hitting Enter on the keyboard. Ideally it would run the fnPopulateList to repopulate the list of names. Is there a way to do that?

try(destroyDialog ::rlRenaming)catch()
rollout rlRenaming "Renaming" 
(
	global names = #("A","B","C","D")
	global index = 0
 
	multiListbox mlName "Names:" width:200 height:6 pos:[10,10]
 
	fn fnPopulateList = (mlName.items = names)
 
	fn fnEditName = (
		try(destroyDialog ::rlEditField)catch()
		rollout rlEditField ("Name Editor")
		(
			label lbValue "Name:" pos:[15,15]
			editText etNewName "" width:75 pos:[50,13]
			button btnSubmit "Apply" width:115 height:30 pos:[15,40]
 
			fn fnApplyChanges = (		
				names[index] = etNewName.text
				try(destroyDialog ::rlEditField)catch()
 
				-- run function to repopulate list from the global names array!!
			)
 
			on etNewName entered txt do fnApplyChanges()
			on btnSubmit pressed do fnApplyChanges()
 
			on rlEditField open do 
			(
				etNewName.text = names[index]
				setfocus etNewName
			)
		)
		createDialog rlEditField 150 80  style:#(#style_SysMenu, #style_ToolWindow)
	)
 
	on mlName doubleClicked itm do (
		index = itm
		fnEditName()
	)
 
	on rlRenaming open do
	(
		fnPopulateList()
	)
)
createDialog rlRenaming 220 120  style:#(#style_SysMenu, #style_ToolWindow)

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
PerfectCell's picture

?

Could you not just put mlName.items = names in the fnApplyChanges function?

fn fnApplyChanges = (
                      names[index] = etNewName.text
                      mlName.items = names
                      try(destroyDialog ::rlEditField)catch()

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.