catch event from WebGadget

Just starting out? Need help? Post your questions and find answers here.
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

catch event from WebGadget

Post by doctorized »

I have some data in a db and I want to present them in a window. It may be used any font and any size to show those data so I do not want to mess with widths and heights. So, I am thinking of making a html code with those data (a table or a list) and show them in a WebGadget. the user will have the ability to delete any of the entries so I am going to have a delete icon for every row in that table or list. Is there a way to catch the left mouse down on the delete icon? Can something like PostEvent() be used inside the html code of the WebGadget?

I am thinking of making something like that without the vertical menu or the left: Image
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: catch event from WebGadget

Post by firace »

It's possible to catch JS click events easily using the document.title trick. Try this example:

Code: Select all

OpenWindow(0, #PB_Ignore, #PB_Ignore, 440, 224, "win1", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

WebGadget(0, 0, 0, 440, 190, "")
SetGadgetItemText(0, #PB_Web_HtmlCode, "<script>document.title='none';</script><html>Item 1  <a href=# onclick=document.title='Delete(item1)'>Delete</a> <BR> Item 2  <a href=# onclick=document.title='Delete(item2)'>Delete</a> </html>")

Repeat
  Event=WaitWindowEvent()
  
  Select Event    
    Case #PB_Event_Gadget
      If EventType()  = #PB_EventType_TitleChange And FindString(GetGadgetItemText(0,#PB_Web_PageTitle), "Delete")  
        Debug GetGadgetItemText(0,#PB_Web_PageTitle) 
      EndIf 
  EndSelect
  
Until Event=#PB_Event_CloseWindow
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: catch event from WebGadget

Post by doctorized »

firace wrote: Sat Sep 18, 2021 10:37 am It's possible to catch JS click events easily using the document.title trick. Try this example:

Code: Select all

........
There will be no "delete" text. There will be an icon instead. The code <a href=# onclick=document.title='Delete(item2)'> solves the problem.

Now I realized another problem. The icon is inside a DataSection. I will retrieve the Image with CatchImage() but how will it be passed to the html code?
infratec
Always Here
Always Here
Posts: 6817
Joined: Sun Sep 07, 2008 12:45 pm
Location: Germany

Re: catch event from WebGadget

Post by infratec »

You can 'store' the images, or embedd them via Base64

https://www.w3docs.com/snippets/html/ho ... -html.html
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: catch event from WebGadget

Post by firace »

Or you can get rid of the embedded image and pick an icon from the Segoe system font instead (included with all modern windows versions):

Code: Select all

OpenWindow(0, #PB_Ignore, #PB_Ignore, 440, 224, "win1", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

WebGadget(0, 0, 0, 440, 190, "")
SetGadgetItemText(0, #PB_Web_HtmlCode, "<script>document.title='none';</script><html><body style='font-family:Segoe UI Emoji; font-size:16px'> Item 1  <a href=# style='text-decoration:none;' onclick=document.title='Delete(item1)'>&#x2716;</a> <BR> Item 2  <a href=# style='text-decoration:none;' onclick=document.title='Delete(item2)'>&#x2716;</a> </html>")

Repeat
  Event=WaitWindowEvent()
  
  Select Event    
    Case #PB_Event_Gadget
      If EventType()  = #PB_EventType_TitleChange And FindString(GetGadgetItemText(0,#PB_Web_PageTitle), "Delete")  
        Debug GetGadgetItemText(0,#PB_Web_PageTitle) 
      EndIf 
  EndSelect
  
Until Event=#PB_Event_CloseWindow

User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: catch event from WebGadget

Post by doctorized »

Thank you infratec!
firace wrote: Sat Sep 18, 2021 1:30 pm Or you can get rid of the embedded image and pick an icon from the Segoe system font instead (included with all modern windows versions):

Code: Select all

...........
My default app font is Arial and the user can set whatever he wants. So, I will use Base64. If there is a better way, I am all ears. (Also, keep in mind that the device may not be connected to the internet to use an online icon.)

EDIT: Is WebGadget so bad?
Image
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: catch event from WebGadget

Post by firace »

You didn't include any code so hard to guess what is wrong, but anyway keep in mind that
the webgadget is simply a wrapper around the default system webview.
On Windows you can turn on better CSS support with the below meta tag.

Code: Select all

OpenWindow(0, #PB_Ignore, #PB_Ignore, 440, 224, "win1", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)

WebGadget(0, 0, 0, 440, 190, "")
SetGadgetItemText(0, #PB_Web_HtmlCode, "<meta http-equiv='X-UA-Compatible' content='IE=edge' /><script>document.title='none';</script><html><body style='font-family:Segoe UI Emoji; font-size:16px'> Item 1  <a href=# style='text-decoration:none;' onclick=document.title='Delete(item1)'>&#x2716;</a> <BR> Item 2  <a href=# style='text-decoration:none;' onclick=document.title='Delete(item2)'>&#x2716;</a> </html>")

Repeat
  Event=WaitWindowEvent()
  
  Select Event    
    Case #PB_Event_Gadget
      If EventType()  = #PB_EventType_TitleChange And FindString(GetGadgetItemText(0,#PB_Web_PageTitle), "Delete")  
        Debug GetGadgetItemText(0,#PB_Web_PageTitle) 
      EndIf 
  EndSelect
  
Until Event=#PB_Event_CloseWindow
User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: catch event from WebGadget

Post by doctorized »

firace wrote: Sun Sep 19, 2021 9:08 am You didn't include any code so hard to guess what is wrong,

Code: Select all

Global HTMLTable.s, HTMLBinIcon.s = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFQElEQVRYhaWXT6hVVRTGf2u/a4n5pJciBSER5ahA7A9EBGGTsEkEwcNBs2ySUAjpwBAriqI/hJZREAQ5qEFDIWhmBUJ/6A9EVqIORCRf4Xua+M7+vgZ7n3Ou7970Vntyz91n772+tda3vrVP8C/Gue1b11r5edubwSuQIZxsy44LEfos7Gen9354YtIzY9KF8zufujGUv3DkdQjAYGNMYGwIm7BOE+m+la+/d2SScweTAmCQ3sBpHQwI8bnJP4IbcLJIWOuBTbLWhrQfeGCSYyeKwMLunSts/WH5qsAHgYemX3h1ZN38jicP2NqSlAn7hmtee/fUfwKwsGfXUGQyYW6y+cUWOD+N2Q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TKZXPXJTa1xdBtyoB6Q+KoUD6lPlSG2ljOutoxxoFou6AKFKwqatBhER1dmmhl5EBRD1LhrOvX2ZVGlgjUrhaAqaHr3tAUDYc5ZnbBNqzgNM2d9Ymim3Ii2U9fmzsGYswHG2OjHor3SjXwFjdCB3l8yAaYCZQ4cE/Dm8bubw4Wbp3Orvvh2Zcy5tuYZjBMDYD5O5u+7+2sHGsM/KfmfKnBMobNXLhiyRHNgNOErQXHtHdrKUgKuBrcZrwhw13Lrmt58uQTEWwJmNd2wi+BQxKB8gpbSjFRXXVm2jcG1KdGITroSMaKOpQI+uPnrkk4kiADB3+4b7sV+yWd82hXIDLtXh2rJN2y1rG2/XIXDI5hj2s6uP/XxwnJ2/ARupRwGNVUeRAAAAAElFTkSuQmCC"


Procedure StartHTMLTable(font.s, fontsize.i)
	HTMLTable = "<html><head><meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=UTF-8" + Chr(34) + "><style>table, th, td {font-family: " + font + "; font-size: " + Str(fontsize+4) + ";}"
	HTMLTable + "tbody tr:nth-child(4n-3){background-color: #e0ffff;}.span_date {max-width:340px;display: block; }.span_data{float: right; width: 32px;}</style></head><body><table width=" + Chr(34) + "400px" + Chr(34) + ">"
EndProcedure

Procedure AddHTMLTableRow(line.i, date.s, text.s)
	;HTMLTable + "<tr><td><span class=" + Chr(34) + "span_date" + Chr(34) + "><b>#" + Str(line) + "</b><br><i>Date: " + date + "</i><br>" + text +"</span><span class=" + Chr(34) + "span_data" + Chr(34) + "><a href=# onclick=document.title='Delete(item" + Str(line) + ")'><img src=" + Chr(34) + "Data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFQElEQVRYhaWXT6hVVRTGf2u/a4n5pJciBSER5ahA7A9EBGGTsEkEwcNBs2ySUAjpwBAriqI/hJZREAQ5qEFDIWhmBUJ/6A9EVqIORCRf4Xua+M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ALMLYChd0qV3RB6xPyYCWXTZL9EgsrFVDq5OhGuj0ZAxVS+z2kiCncIFZBeVy0bAuXqujgNS7ZBDJGwPNLknl3JJk4ZUrzayJPdVdTkAyLJLvbbLk1Tai4byqGp4qNOFXMHGEKj6XiKIK5NQHdmGhiu7JVJ9Y9WKcGnDAK63InLT3SOSnJCqHoy4OyYFtKHtGjrk3lO7rQKVdVm9wJfLKJJ7DVHTGY5JALipTKZXPXJTa1xdBtyoB6Q+KoUD6lPlSG2ljOutoxxoFou6AKFKwqatBhER1dmmhl5EBRD1LhrOvX2ZVGlgjUrhaAqaHr3tAUDYc5ZnbBNqzgNM2d9Ymim3Ii2U9fmzsGYswHG2OjHor3SjXwFjdCB3l8yAaYCZQ4cE/Dm8bubw4Wbp3Orvvh2Zcy5tuYZjBMDYD5O5u+7+2sHGsM/KfmfKnBMobNXLhiyRHNgNOErQXHtHdrKUgKuBrcZrwhw13Lrmt58uQTEWwJmNd2wi+BQxKB8gpbSjFRXXVm2jcG1KdGITroSMaKOpQI+uPnrkk4kiADB3+4b7sV+yWd82hXIDLtXh2rJN2y1rG2/XIXDI5hj2s6uP/XxwnJ2/ARupRwGNVUeRAAAAAElFTkSuQmCC" + Chr(34) + "></a></span></td></tr>"
	HTMLTable + "<tr><td><span class=" + Chr(34) + "span_date" + Chr(34) + "><b>#" + Str(line) + "</b><br><i>Date: " + date + "</i><br>" + text +"</span><span class=" + Chr(34) + "span_data" + Chr(34) + "><a href=# onclick=document.title='Delete(item" + Str(line) + ")'><img src=" + Chr(34) + "Data:image/png;base64," + HTMLBinIcon + Chr(34) + "></a></span></td></tr>"
	HTMLTable + "<tr><td colspan=" + Chr(34) + "2" + Chr(34) + "><hr></td></tr>"
	
	;ShowMemoryViewer(@HTMLBinIcon,1896)
	;Debug HTMLBinIcon
EndProcedure

Procedure EndHTMLTable()
	HTMLTable + "</table></body></html>"
EndProcedure

StartHTMLTable("Arial",11)
For i= 1 To 9
	AddHTMLTableRow(i,"15-09-2021","jgfkjg kfljg fkj fkjg fkjg  klfj gfglk jflkg jflkjglkfjglkfj glfkjg lfkjg lkfj glkfjg lkfjg lfkgj flkjg")
Next
EndHTMLTable()


 If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 	WebGadget(0, 10, 10, 580, 280, "")
 	SetGadgetItemText(0,#PB_Web_HtmlCode,HTMLTable)
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: catch event from WebGadget

Post by firace »

Code: Select all

Global HTMLTable.s, HTMLBinIcon.s = "iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFQElEQVRYhaWXT6hVVRTGf2u/a4n5pJciBSER5ahA7A9EBGGTsEkEwcNBs2ySUAjpwBAriqI/hJZREAQ5qEFDIWhmBUJ/6A9EVqIORCRf4Xua+M7+vgZ7n3Ou7970Vntyz91n772+tda3vrVP8C/Gue1b11r5edubwSuQIZxsy44LEfos7Gen9354YtIzY9KF8zufujGUv3DkdQjAYGNMYGwIm7BOE+m+la+/d2SScweTAmCQ3sBpHQwI8bnJP4IbcLJIWOuBTbLWhrQfeGCSYyeKwMLunSts/WH5qsAHgYemX3h1ZN38jicP2NqSlAn7hmtee/fUfwKwsGfXUGQyYW6y+cUWOD+N2QeAc0lBDqABs8VuPkgydr4H+Su8CAIpk+xm+q0D/wxgYc+ua4HDwM2ghA2GCJCdQsbKIsCYpMIBnCEbANGkpAxYZBFusIzVKKSTtu5Ztf/jk63NtMT52wzrQQPbCUgByXYFkyFIZZ+Tcf0lESSjlAw4AKcQCUfZjweYdcCdwwY7AAu7n3kw3GyHDDZBYbVxF6ryVFgfqv+sUg02JS6ZtkIIYbdmoqTLfuLs1kceGQFgYqOJh5OoxgNXo7ZxNQi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whw13Lrmt58uQTEWwJmNd2wi+BQxKB8gpbSjFRXXVm2jcG1KdGITroSMaKOpQI+uPnrkk4kiADB3+4b7sV+yWd82hXIDLtXh2rJN2y1rG2/XIXDI5hj2s6uP/XxwnJ2/ARupRwGNVUeRAAAAAElFTkSuQmCC"


Procedure StartHTMLTable(font.s, fontsize.i)
	HTMLTable = "<html><head><meta http-equiv=X-UA-Compatible content=IE=edge /><meta http-equiv=" + Chr(34) + "Content-Type" + Chr(34) + " content=" + Chr(34) + "text/html; charset=UTF-8" + Chr(34) + "><style>table, th, td {font-family: " + font + "; font-size: " + Str(fontsize+4) + ";}"
	HTMLTable + "tbody tr:nth-child(4n-3){background-color: #e0ffff;}.span_date {max-width:340px;display: block; }.span_data{float: right; width: 32px;}</style></head><body><table width=" + Chr(34) + "400px" + Chr(34) + ">"
EndProcedure

Procedure AddHTMLTableRow(line.i, date.s, text.s)
	;HTMLTable + "<tr><td><span class=" + Chr(34) + "span_date" + Chr(34) + "><b>#" + Str(line) + "</b><br><i>Date: " + date + "</i><br>" + text +"</span><span class=" + Chr(34) + "span_data" + Chr(34) + "><a href=# onclick=document.title='Delete(item" + Str(line) + ")'><img src=" + Chr(34) + "Data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAACAAAAAgCAYAAABzenr0AAAACXBIWXMAAA7EAAAOxAGVKw4bAAAFQElEQVRYhaWXT6hVVRTGf2u/a4n5pJciBSER5ahA7A9EBGGTsEkEwcNBs2ySUAjpwBAriqI/hJZREAQ5qEFDIWhmBUJ/6A9EVqIORCRf4Xua+M7+vgZ7n3Ou7970Vntyz91n772+tda3vrVP8C/Gue1b11r5edubwSuQIZxsy44LEfos7Gen9354YtIzY9KF8zufujGUv3DkdQjAYGNMYGwIm7BOE+m+la+/d2SScweTAmCQ3sBpHQwI8bnJP4IbcLJIWOuBTbLWhrQfeGCSYyeKwMLunSts/WH5qsAHgYemX3h1ZN38jicP2NqSlAn7hmtee/fUfwKwsGfXUGQyYW6y+cUWOD+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JALipTKZXPXJTa1xdBtyoB6Q+KoUD6lPlSG2ljOutoxxoFou6AKFKwqatBhER1dmmhl5EBRD1LhrOvX2ZVGlgjUrhaAqaHr3tAUDYc5ZnbBNqzgNM2d9Ymim3Ii2U9fmzsGYswHG2OjHor3SjXwFjdCB3l8yAaYCZQ4cE/Dm8bubw4Wbp3Orvvh2Zcy5tuYZjBMDYD5O5u+7+2sHGsM/KfmfKnBMobNXLhiyRHNgNOErQXHtHdrKUgKuBrcZrwhw13Lrmt58uQTEWwJmNd2wi+BQxKB8gpbSjFRXXVm2jcG1KdGITroSMaKOpQI+uPnrkk4kiADB3+4b7sV+yWd82hXIDLtXh2rJN2y1rG2/XIXDI5hj2s6uP/XxwnJ2/ARupRwGNVUeRAAAAAElFTkSuQmCC" + Chr(34) + "></a></span></td></tr>"
	HTMLTable + "<tr><td><span class=" + Chr(34) + "span_date" + Chr(34) + "><b>#" + Str(line) + "</b><br><i>Date: " + date + "</i><br>" + text +"</span><span class=" + Chr(34) + "span_data" + Chr(34) + "><a href=# onclick=document.title='Delete(item" + Str(line) + ")'><img src=" + Chr(34) + "Data:image/png;base64," + HTMLBinIcon + Chr(34) + "></a></span></td></tr>"
	HTMLTable + "<tr><td colspan=" + Chr(34) + "2" + Chr(34) + "><hr></td></tr>"
	
	;ShowMemoryViewer(@HTMLBinIcon,1896)
	;Debug HTMLBinIcon
EndProcedure

Procedure EndHTMLTable()
	HTMLTable + "</table></body></html>"
EndProcedure

StartHTMLTable("Arial",11)
For i= 1 To 9
	AddHTMLTableRow(i,"15-09-2021","jgfkjg kfljg fkj fkjg fkjg  klfj gfglk jflkg jflkjglkfjglkfj glfkjg lfkjg lkfj glkfjg lkfjg lfkgj flkjg")
Next
EndHTMLTable()


 If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
 	WebGadget(0, 10, 10, 580, 280, "")
 	SetGadgetItemText(0,#PB_Web_HtmlCode,HTMLTable)
    ; Note: if you want to use a local file, change last parameter to "file://" + path + filename
    Repeat
    Until WaitWindowEvent() = #PB_Event_CloseWindow
  EndIf

User avatar
doctorized
Addict
Addict
Posts: 854
Joined: Fri Mar 27, 2009 9:41 am
Location: Athens, Greece

Re: catch event from WebGadget

Post by doctorized »

firace wrote: Sun Sep 19, 2021 7:45 pm

Code: Select all

<meta http-equiv=X-UA-Compatible content=IE=edge />
This solved the problem. Thank you very much!!
firace
Addict
Addict
Posts: 899
Joined: Wed Nov 09, 2011 8:58 am

Re: catch event from WebGadget

Post by firace »

doctorized wrote: Sun Sep 19, 2021 8:08 pm
firace wrote: Sun Sep 19, 2021 7:45 pm

Code: Select all

<meta http-equiv=X-UA-Compatible content=IE=edge />
This solved the problem. Thank you very much!!
Thanks! Good to know that it helped.
User avatar
captain_skank
Enthusiast
Enthusiast
Posts: 636
Joined: Fri Oct 06, 2006 3:57 pm
Location: England

Re: catch event from WebGadget

Post by captain_skank »

I also use the webgadget as a customisable table, but i use hyperlinks to provide feedback :

Code: Select all

Procedure.s PROC_html()
  
  ; -----------------------------------------------------------------------
  ; declare local variables
  ; -----------------------------------------------------------------------
  Protected LVAR_html.s
  ; -----------------------------------------------------------------------
  
  LVAR_html = "<!DOCTYPE html>" + #CRLF$
  LVAR_html + "<HTML>" + #CRLF$
  LVAR_html + "<HEAD>" + #CRLF$
  LVAR_html + "</HEAD>" + #CRLF$
  LVAR_html + "<BODY>" + #CRLF$
  LVAR_html + "<h3><A href='LINK1'>The standard Lorem Ipsum passage, used since the 1500s</A></h3><p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p><A href='LINK2'><h3>Section 1.10.32 of 'de Finibus Bonorum et Malorum', written by Cicero in 45 BC</A></h3><p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt. Neque porro quisquam est, qui dolorem ipsum quia dolor sit amet, consectetur, adipisci velit, sed quia non numquam eius modi tempora incidunt ut labore et dolore magnam aliquam quaerat voluptatem. Ut enim ad minima veniam, quis nostrum exercitationem ullam corporis suscipit laboriosam, nisi ut aliquid ex ea commodi consequatur? Quis autem vel eum iure reprehenderit qui in ea voluptate velit esse quam nihil molestiae consequatur, vel illum qui dolorem eum fugiat quo voluptas nulla pariatur?</p>" + #CRLF$
  LVAR_html + "<h3><A href='LINK3'>1914 translation by H. Rackham</A></h3>" + #CRLF$
  LVAR_html + "<p>But I must explain To you how all this mistaken idea of denouncing pleasure And praising pain was born And I will give you a complete account of the system, And expound the actual teachings of the great explorer of the truth, the master-builder of human happiness. No one rejects, dislikes, Or avoids pleasure itself, because it is pleasure, but because those who do Not know how To pursue pleasure rationally encounter consequences that are extremely painful. Nor again is there anyone who loves Or pursues Or desires To obtain pain of itself, because it is pain, but because occasionally circumstances occur in which toil And pain can procure him some great pleasure. To take a trivial example, which of us ever undertakes laborious physical exercise, except To obtain some advantage from it? But who has any right To find fault With a man who chooses To enjoy a pleasure that has no annoying consequences, Or one who avoids a pain that produces no resultant pleasure?</p>" + #CRLF$
  LVAR_html + "<h3><A href='LINK4'>Section 1.10.33 of 'de Finibus Bonorum et Malorum', written by Cicero in 45 BC</A></h3>" + #CRLF$
  LVAR_html + "<p>At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Temporibus autem quibusdam et aut officiis debitis aut rerum necessitatibus saepe eveniet ut et voluptates repudiandae sint et molestiae non recusandae. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.</p>" + #CRLF$
  LVAR_html + "<h3>1914 translation by H. Rackham</h3>" + #CRLF$
  LVAR_html + "<p>On the other hand, we denounce With righteous indignation And dislike men who are so beguiled And demoralized by the charms of pleasure of the moment, so blinded by desire, that they cannot foresee the pain And trouble that are bound To ensue; and equal blame belongs to those who fail in their duty through weakness of will, which is the same as saying through shrinking from toil and pain. These cases are perfectly simple and easy to distinguish. In a free hour, when our power of choice is untrammelled and when nothing prevents our being able to do what we like best, every pleasure is to be welcomed and every pain avoided. But in certain circumstances and owing to the claims of duty or the obligations of business it will frequently occur that pleasures have to be repudiated and annoyances accepted. The wise man therefore always holds in these matters to this principle of selection: he rejects pleasures to secure other greater pleasures, or else he endures pains to avoid worse pains.</p>" + #CRLF$
  LVAR_html + "</div>" + #CRLF$
  LVAR_html + "</BODY>" + #CRLF$
  LVAR_html + "</HTML>"
  
  ProcedureReturn LVAR_html
  
EndProcedure
  
  
  
Procedure.l PROC_web_events(PVAR_gid.i, PVAR_url.s)
  
  ; -----------------------------------------------------------------------
  ; declare local variables
  ; -----------------------------------------------------------------------
  Protected LVAR_link.s ; placeholder for url sent by webpage hyperlink
  ; -----------------------------------------------------------------------
  
  ; ------------------------------------------------------
  ; format data passed by hyperlink
  ; ------------------------------------------------------
  ; first remove about or blank - inserted by browser
  ; ------------------------------------------------------

  LVAR_link.s = RemoveString(PVAR_url, "about:", #PB_String_NoCase)
  LVAR_link = RemoveString(LVAR_link, "blank", #PB_String_NoCase)
  
  If Len(LVAR_link) > 0
    
    ; you custom actions here
    Debug LVAR_link
    
  EndIf
  
EndProcedure


  
  
If OpenWindow(0, 0, 0, 600, 300, "Hyperlink example", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  
  WebGadget(0, 10, 10, 580, 280, "")
  
  ; hook webgadget events
  SetGadgetAttribute(0, #PB_Web_NavigationCallback, @PROC_web_events())
  
  ; Set webgadget HTML
  SetGadgetItemText(0, #PB_Web_HtmlCode, PROC_html())
  
  Repeat 
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow 
  
EndIf
Post Reply