So, you should not use callbacks (they are there only for very specific uses). You should just use the value returned after you called a form, like:newt does not use an event-driven architecture.
....
This means that newt applications look dramatically different from programs written for event-driven architectures such as Motif, gtk, or even Borland's old TurboVision libraries. When you're designing your newt program, keep this differentiation in mind. As long as you plan your application to call a function to get input and then continue (rather then having your program called when input is ready), programming with the newt libraries should be simple.
Code: Select all
#Ifndef NULL
#Define NULL 0
#Endif
#inclib "newt"
#include "newt.bi"
dim form as newtComponent
dim b1 as newtComponent
dim b2 as newtComponent
dim p as newtComponent
sub fCallback()
newtCls()
newtDrawRootText(0, 0, strptr("I am in callback!"))
newtRefresh()
end sub
newtInit()
newtCls()
newtOpenWindow(10, 5, 40, 6, "Button Sample")
b1 = newtButton(10, 1, "Ok")
b2 = newtCompactButton(22, 2, "Cancel")
form = newtForm(NULL, NULL, 0)
newtFormAddComponents(form, b1, b2, NULL)
p=newtRunForm(form)
if p=b1 then fCallback()
sleep
newtFormDestroy(form)
newtFinished()