Morning All, hope everyone is well and staying safe.
Is it even possible to catch an event from a webgadget other than a hyperlink.
E.G a button or a checkbox
I've tried googling with all sorts of permutations but haven't found anything
Cheers
Capture webgadget events
- captain_skank
- Enthusiast
- Posts: 636
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Capture webgadget events
Did you already try the following examples?
Detect button click:
- Sparkie
- utopiomania
- Kiffi
Detect selected option in dropdown list:
- viiartz (modified by Shardik)
Detect button click:
- Sparkie
- utopiomania
- Kiffi
Detect selected option in dropdown list:
- viiartz (modified by Shardik)
- captain_skank
- Enthusiast
- Posts: 636
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: Capture webgadget events
Thanks for the links - pointed me in the right direction.
Heres what i cobbled up ( not using a stock button ) :
Heres what i cobbled up ( not using a stock button ) :
Code: Select all
Declare.s PROC_create_web_hex(PVAR_colour.i)
Declare.i PROC_tint_rgb(PVAR_rgb.i, PVAR_percentage.i)
Declare.i PROC_populate_table(PVAR_wid.i, PVAR_gid.i)
Declare.i PROC_populate_table_2(PVAR_wid.i, PVAR_gid.i)
Declare.l PROC_display_main_table_events(gadget, url.s)
Global GBL_layer_border.i = 16750848
Global GBL_layer_background.i = 16448250
Global GBL_layer_text.i = 16777215
Global GBL_layer_alternate_text.i = 0
Procedure.s PROC_create_web_hex(PVAR_colour.i)
ProcedureReturn "#" + RSet(Hex(Red(PVAR_colour)), 2, "0") + RSet(Hex(Green(PVAR_colour)), 2, "0") + RSet(Hex(Blue(PVAR_colour)), 2, "0")
EndProcedure
Procedure.i PROC_tint_rgb(PVAR_rgb.i, PVAR_percentage.i)
; ---------------------------------------------------------------------------
; P U R P O S E
; ---------------------------------------------------------------------------
; Lightens or darkens the RGB value passed by the percentage value passed
; ---------------------------------------------------------------------------
; I N P U T S
; ---------------------------------------------------------------------------
; PVAR_rgb.i -> A colour in RGB format
; PVAR_percentage.i -> The percentage to lighten or darken the original
; colour ( 0 To 100 )
; ---------------------------------------------------------------------------
; D E C L A R E L O C A L V A R I A B L E S
; ---------------------------------------------------------------------------
LVAR_text_line.s ; Used for storing lines read from file
LVAR_r.i ; the red value of the passed rgb colour
LVAR_g.i ; the green value of the passed rgb colour
LVAR_b.i ; the blue value of the passed rgb colour
LVAR_p.d ; the percentage to change the rgb colour by
; ---------------------------------------------------------------------------
LVAR_r = Red(PVAR_rgb)
LVAR_g = Green(PVAR_rgb)
LVAR_b = Blue(PVAR_rgb)
LVAR_p = PVAR_percentage / 100
LVAR_r = LVAR_r + (255 - LVAR_r) * LVAR_p
LVAR_g = LVAR_g + (255 - LVAR_g) * LVAR_p
LVAR_b = LVAR_b + (255 - LVAR_b) * LVAR_p
ProcedureReturn RGB(LVAR_r, LVAR_g, LVAR_b)
EndProcedure
Procedure.i PROC_populate_table_2(PVAR_wid.i, PVAR_gid.i)
LVAR_html.s
LVAR_html = ""
LVAR_html = "<!DOCTYPE html>" + #CRLF$
LVAR_html + "<HTML>" + #CRLF$
LVAR_html + "<HEAD>" + #CRLF$
;{ Build the <STYLE>
LVAR_html + "<STYLE TYPE='text/css'> " + #CRLF$
LVAR_html + "BODY {" + #CRLF$
LVAR_html + "background-color: " + PROC_create_web_hex(GBL_layer_text) + "; " + #CRLF$
LVAR_html + "color: " + PROC_create_web_hex(GBL_layer_alternate_text) + "; " + #CRLF$
LVAR_html + "font-family: Arial;" + #CRLF$
LVAR_html + "scroll = 'no';"
LVAR_html + "oncontextmenu = 'javascript:return false;'"
LVAR_html + "} " + #CRLF$
LVAR_html + ".button " + #CRLF$
LVAR_html + "{ " + #CRLF$
LVAR_html + "background-color: #4CAF50; /* Green */ " + #CRLF$
LVAR_html + "border: none; " + #CRLF$
LVAR_html + "color: white; " + #CRLF$
LVAR_html + "padding: 16px 32px; " + #CRLF$
LVAR_html + "text-align: center; " + #CRLF$
LVAR_html + "text-decoration: none; " + #CRLF$
LVAR_html + "display: inline-block; " + #CRLF$
LVAR_html + "font-size: 16px; " + #CRLF$
LVAR_html + "margin: 0px 0px; " + #CRLF$
LVAR_html + "transition-duration: 0.4s; " + #CRLF$
LVAR_html + "cursor: pointer; " + #CRLF$
LVAR_html + "} " + #CRLF$
LVAR_html + ".button1 " + #CRLF$
LVAR_html + "{ " + #CRLF$
LVAR_html + "background-color: " + PROC_create_web_hex(GBL_layer_border) + "; " + #CRLF$
LVAR_html + "color: " + PROC_create_web_hex(GBL_layer_text) + "; " + #CRLF$
LVAR_html + "border-left: 1px solid " + PROC_create_web_hex(PROC_tint_rgb(GBL_layer_border, 50)) + "; " + #CRLF$
LVAR_html + "border-top: 1px solid " + PROC_create_web_hex(PROC_tint_rgb(GBL_layer_border, 50)) + "; " + #CRLF$
LVAR_html + "border-right: 1px solid " + PROC_create_web_hex(PROC_tint_rgb(GBL_layer_border, 50)) + "; " + #CRLF$
LVAR_html + "} " + #CRLF$
LVAR_html + ".button1:hover " + #CRLF$
LVAR_html + "{ " + #CRLF$
LVAR_html + "background-color: " + PROC_create_web_hex(PROC_tint_rgb(GBL_layer_border, 50)) + "; " + #CRLF$
LVAR_html + "color: " + PROC_create_web_hex(GBL_layer_text) + "; " + #CRLF$
LVAR_html + "} " + #CRLF$
LVAR_html + "</STYLE>" + #CRLF$
;}
LVAR_html + "</HEAD>" + #CRLF$
LVAR_html + "<body scroll = 'no' oncontextmenu = 'javascript:return false;'>" + #CRLF$
LVAR_html + "<button class=" + #DQUOTE$ + "button button1" + #DQUOTE$ + " onclick='window.location=" + #DQUOTE$ +"btn_1" + #DQUOTE$ + "'>Button 2</button>" + #CRLF$
LVAR_html + "<button class=" + #DQUOTE$ + "button button1" + #DQUOTE$ + " onclick='window.location=" + #DQUOTE$ +"btn_2" + #DQUOTE$ + "'>Button 2</button>" + #CRLF$
LVAR_html + "<button class=" + #DQUOTE$ + "button button1" + #DQUOTE$ + " onclick='window.location=" + #DQUOTE$ +"btn_3" + #DQUOTE$ + "'>Button 3</button>" + #CRLF$
LVAR_html + "<button class=" + #DQUOTE$ + "button button1" + #DQUOTE$ + " onclick='window.location=" + #DQUOTE$ +"btn_4" + #DQUOTE$ + "'>Button 4</button>" + #CRLF$
LVAR_html + "<button class=" + #DQUOTE$ + "button button1" + #DQUOTE$ + " onclick='window.location=" + #DQUOTE$ +"btn_5" + #DQUOTE$ + "'>Button 5</button>" + #CRLF$
LVAR_html + "</BODY>" + #CRLF$
LVAR_html + "</HTML>"
Debug LVAR_html
SetGadgetItemText(PVAR_gid, #PB_Web_HtmlCode, LVAR_html)
; hook webgadget events
SetGadgetAttribute(PVAR_gid, #PB_Web_NavigationCallback, @PROC_display_main_table_events())
;SetGadgetAttribute(fld_wp_view_grid, #PB_Web_BlockPopupMenu,1)
; repaint the calling window
;RedrawWindow_(WindowID(PVAR_wid),#NUL,#NUL,#RDW_ALLCHILDREN|#RDW_INVALIDATE)
EndProcedure
Procedure.l PROC_display_main_table_events(gadget, url.s)
Debug "PROC_display_main_table_events()"
Debug "Raw LINK : " + url
; ------------------------------------------------------
; format data passed by hyperlink
; ------------------------------------------------------
; first remove about or blank - inserted by browser
; ------------------------------------------------------
link.s = RemoveString(url, "about:", #PB_String_NoCase)
link = RemoveString(link, "blank", #PB_String_NoCase)
Debug link
EndProcedure
WNDW_main.i = OpenWindow(#PB_Any, 0, 0, 1000, 400, "A window", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
If WNDW_main
LVAR_ww.i = WindowWidth(WNDW_main)
LVAR_wh.i = WindowHeight(WNDW_main)
Global fld_main_table.i = WebGadget(#PB_Any, 15, 15, LVAR_ww -30, LVAR_wh-30, "")
WNDW_main_quit.i = #False
PROC_populate_table_2(WNDW_main, fld_main_table )
Else
End
EndIf
Repeat
LVAR_event.i = WaitWindowEvent()
Select LVAR_event
Case #PB_Event_CloseWindow
WNDW_main_quit = #True
EndSelect
Until WNDW_main_quit = #True