I think the KB would benefit from a simple introductory example that concentrated on button actions. I put this example together to illustrate. Three simple buttons, with two clickable actions and a close button. The close button demonstrates an action that closes the window and ends the plugin, while the other two can be called repeatedly in a loop.
Code: Select all
require('iuplua');
iup.SetGlobal('CUSTOMQUITMESSAGE','YES');
function main()
-- define three buttons with a minimum of formatting
btn1 = iup.button{title='1',size='40x'}
btn2 = iup.button{title='2',size='40x'}
btnCancel = iup.button{title='Cancel',size='40x'}
-- define what the buttons do when clicked
function btn1:action()
dlg:hide()
btn1_Click()
dlg:show()
end
function btn2:action()
dlg:hide()
btn2_Click()
dlg:show()
end
function btnCancel:action()
return iup.CLOSE
end
-- define the form layout
buttons = iup.hbox{btn1, btn2, btnCancel}
dlg = iup.dialog{buttons}
dlg:show()
iup.MainLoop()
end
function btn1_Click()
fhMessageBox('1 clicked!')
end
function btn2_Click()
fhMessageBox('2 clicked!')
end
main()
Curiously, if I don't hide the menu while the simple fhMessageBox() illustrations are waiting for an answer, it stays active, so I can have two modal dialogue boxes open at the same time! I don't know if that is just a curious quirk or a warning of something sinister in the code.