Task

Create a window that has:

   a label that says   "There have been no clicks yet" 
   a button that says   "click me"


Upon clicking the button with the mouse, the label should change and show the number of times the button has been clicked.




-- demo\rosetta\Simple_window.exw
with javascript_semantics
include pGUI.e
 
Ihandle dlg, lbl, btn, vbox
integer clicks = 0
 
function click_cb(Ihandle /*btn*/)
    clicks += 1
    IupSetStrAttribute(lbl,"TITLE","clicked %d times",{clicks})
    return IUP_DEFAULT;
end function
 
IupOpen()
lbl = IupLabel("There have been no clicks yet")
btn = IupButton("Click me", Icallback("click_cb"))
vbox = IupVbox({lbl, IupHbox({IupFill(),btn,IupFill()})})
dlg = IupDialog(vbox,"MARGIN=10x10, GAP=10, RASTERSIZE=400x0")
IupSetAttribute(dlg, "TITLE", "Simple windowed application")
IupShow(dlg)
if platform()!=JS then
    IupMainLoop()
    IupClose()
end if
