; Windows / Extended mode. Run from this folder or its exported copy. Local ui=LoadNativeUI("workbench.ui") If ui=0 Then RuntimeError NativeUIError() Local canvas=FindNativeGadget(ui,"viewport"),name=FindNativeGadget(ui,"name"),message=FindNativeGadget(ui,"message") Local speed=FindNativeGadget(ui,"speed"),moving=FindNativeGadget(ui,"moving"),progress=FindNativeGadget(ui,"progress") If NativeCanvasRole(ui,canvas)<>"preview" Then RuntimeError "Expected preview canvas role" ; Live world/camera ownership belongs to the application, not the document. Graphics3DCanvas canvas Local world=GetWorld(),camera=CreateCamera(),cube=CreateCube(),light=CreateLight(1) PositionEntity camera,0,1,-6:RotateEntity camera,8,0,0:RotateEntity light,25,-30,0 EntityColor cube,80,170,225:AmbientLight 95,95,95 SetCanvasCamera canvas,camera If ShowNativeUI(ui)=False Then RuntimeError NativeUIError() Local running=True,lastTick=MilliSecs(),phase#=0 While running Local event=WaitEvent(16),source=EventSource(),id$=NativeGadgetID(ui,source) If event=EVENT_WINDOW_CLOSE And source=ui Then running=False If event=EVENT_GADGET_ACTION Then Select id Case "apply" SetGadgetText message,"Hello, "+TextFieldText(name)+". The button was found by stable ID." Case "choose" Local file$=RequestFile("Choose a file to display its path","*",False) If file<>"" Then SetGadgetText message,file Case "close" running=False End Select EndIf Local now=MilliSecs(),elapsed#=Float(now-lastTick)*.001:lastTick=now If elapsed>.1 Then elapsed=.1 If ButtonState(moving) Then TurnEntity cube,elapsed*15,elapsed*TrackBarValue(speed),0 phase=phase+elapsed*.12:If phase>1 Then phase=phase-1 EndIf UpdateProgBar progress,phase SetGadgetText FindNativeGadget(ui,"dpi"),"Window DPI: "+WindowDpi(ui)+" | Resize or move between monitors" If running Then RenderWorldToCanvas canvas,world:FlipCanvas canvas,False Wend SetCanvasCamera canvas,0 FreeEntity cube:FreeEntity camera:FreeEntity light FreeNativeUI ui:EndGraphics:End