Hi nicolaus, this is a working but very simple example. Right click and select view source to see the html,
the PB source reads the navigation, cancel it, then can reload the html user interface. With a bit of dhtml,
the possibilities are limitless, and you can build the interface any way you want.
Code: Select all
;-program notes
;-initialize
;-
Enumeration
#WIN
#WEB
EndEnumeration
Global winW, winH
Declare openMainWindow()
Declare navigationCallback(id, url.s)
Declare.s userInterfacePage1()
;-program entry
openMainWindow()
;-program event handler
Repeat
event = WaitWindowEvent()
Select event
Case #PB_Event_SizeWindow
; winW = WindowWidth(#WIN)
; winH = WindowHeight(#WIN)
; ResizeGadget(#WEB, 0, 0, winW, winH)
Case #PB_Event_CloseWindow
;-program exit
;-
End
EndSelect
ForEver
Procedure openMainWindow()
;$CF0001
ExamineDesktops()
winW = DesktopWidth(0)
winH = DesktopHeight(0)
If OpenWindow(#WIN, 0, 0, winW, winH, "", #PB_Window_BorderLess | #PB_Window_Maximize)
WebGadget(#WEB, 0, 0, winW, winH, "")
;load the html
SetGadgetItemText(#WEB, #PB_Web_HtmlCode, userInterfacePage1())
;callback to monitor window.navigate
SetGadgetAttribute(#WEB, #PB_Web_NavigationCallback, @navigationCallback())
;SetGadgetAttribute(#WEB, #PB_Web_BlockPopupMenu, 1)
EndIf
EndProcedure
Procedure navigationCallback(id, url.s)
url = LCase(url)
If FindString(url, "button01_clicked")
MessageRequester("UI Event handler", url)
ElseIf FindString(url, "button02_clicked")
MessageRequester("UI Event handler", url)
End
EndIf
;block drag-drop
ProcedureReturn 0
EndProcedure
Procedure.s userInterfacePage1()
;html
s.s + "<!doctype html>" + Chr(13)
s + "<html>" + Chr(13)
s + "<head>" + Chr(13)
s + "" + Chr(13)
s + "<style>" + Chr(13)
s + "<!-- body -->" + Chr(13)
s + "body" + Chr(13)
s + "{ background-color: #000000; color: #FFFFFF; " + Chr(13)
s + "font-family:'consolas'; font-size:20px; font-style:bold }" + Chr(13)
s + "" + Chr(13)
s + "<!-- div classes -->" + Chr(13)
s + ".norm { background-color: #000000; color:#606060; position:fixed }" + Chr(13)
s + ".over { background-color: #4040FF; color:#FFFFFF; position:fixed; cursor:hand }" + Chr(13)
s + "</style>" + Chr(13)
s + "" + Chr(13)
s + "<script language=JavaScript>" + Chr(13)
s + "" + Chr(13)
; s + "<!-- disable contextmenu -->" + Chr(13)
; s + "" + Chr(13)
; s + "function nocontextmenuIE(){" + Chr(13)
; s + "if (navigator.appName == 'Microsoft Internet Explorer' && event.button == 2)" + Chr(13)
; s + " return false;" + Chr(13)
; s + "}" + Chr(13)
; s + "function nocontextmenuNS(e){" + Chr(13)
; s + " if ((document.layers || document.getElementById && !document.all) && e.which == 2) {" + Chr(13)
; s + " return false;" + Chr(13)
; s + " }" + Chr(13)
; s + "}" + Chr(13)
; s + "if (document.layers){" + Chr(13)
; s + " document.captureEvents(Event.mousedown);" + Chr(13)
; s + " document.onmousedown = nocontextmenuNS;" + Chr(13)
; s + "}" + Chr(13)
; s + "else if (document.all && !document.getElementById){" + Chr(13)
; s + " document.onmousedown = nocontextmenuIE;" + Chr(13)
; s + "}" + Chr(13)
; s + "document.oncontextmenu = new Function('return false')" + Chr(13)
s + "" + Chr(13)
s + "<!-- user interface event handler -->" + Chr(13)
s + "function eventhandler(event) {" + Chr(13)
s + " window.navigate(event)" + Chr(13)
s + "}" + Chr(13)
s + "</script>" + Chr(13)
s + "" + Chr(13)
s + "</head>" + Chr(13)
s + "<body scroll = 'no'>" + Chr(13)
s + "" + Chr(13)
s + "<!-- Button 1 -->" + Chr(13)
s + "<div style = " + Chr(34) + "left:40%; top:4px; width:150px; height:24px;" + Chr(34) + " " + Chr(13)
s + " class = " + Chr(34) + "norm" + Chr(34) + "; " + Chr(13)
s + " onmouseover = " + Chr(34) + "this.className = 'over'" + Chr(34) + "; " + Chr(13)
s + " onmouseout = " + Chr(34) + "this.className = 'norm'" + Chr(34) + ";" + Chr(13)
s + " onclick = eventhandler(" + Chr(34) + "Button01_CLICKED" + Chr(34) + "); >" + Chr(13)
s + " " + Chr(13)
s + " <center>Filer" + Chr(13)
s + "</div>" + Chr(13)
s + "" + Chr(13)
s + "<!-- Button 2 -->" + Chr(13)
s + "<div style = " + Chr(34) + "left:48%; top:4px; width:150px; height:24px;" + Chr(34) + " " + Chr(13)
s + " class = " + Chr(34) + "norm" + Chr(34) + " " + Chr(13)
s + " onmouseover = " + Chr(34) + "this.className='over'" + Chr(34) + "; " + Chr(13)
s + " onmouseout = " + Chr(34) + "this.className='norm'" + Chr(34) + ";" + Chr(13)
s + " onclick = eventhandler(" + Chr(34) + "Button02_CLICKED" + Chr(34) + "); >" + Chr(13)
s + " " + Chr(13)
s + " <center>Innstill" + Chr(13)
s + "</div>" + Chr(13)
s + "" + Chr(13)
s + "</body>" + Chr(13)
s + "</html>" + Chr(13)
ProcedureReturn s
EndProcedure