Page 1 of 1

What URL is in webgadget

Posted: Fri Nov 23, 2012 9:54 pm
by jesperbrannmark
Sorry for doubleposting.
But there must be a intelligent workaround for this issue
http://www.purebasic.fr/english/viewtop ... 24&t=52168

To just get the URL of a current webgadget? Maybe CocoaMessage?

Re: What URL is in webgadget

Posted: Fri Nov 23, 2012 9:57 pm
by Kiffi
with #PB_Web_NavigationCallback?

Code: Select all

Procedure NavigationCallback(Gadget, Url$) 
  Debug Url$
  ProcedureReturn #True 
EndProcedure 

If OpenWindow(0, 0, 0, 600, 300, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
 WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com") 
 SetGadgetAttribute(0, #PB_Web_NavigationCallback, @NavigationCallback())
 Repeat 
 Until WaitWindowEvent() = #PB_Event_CloseWindow 
EndIf
(don't know if it works under MacOS)

Greetings ... Kiffi

Re: What URL is in webgadget

Posted: Fri Nov 23, 2012 10:02 pm
by jesperbrannmark
Thanks. But no :-(
The navigationcallback is windows only...

Re: What URL is in webgadget

Posted: Sat Nov 24, 2012 7:27 am
by wilbert

Code: Select all

URL.s = PeekS(CocoaMessage(0, CocoaMessage(0, GadgetID(0), "mainFrameURL"), "UTF8String"), -1, #PB_UTF8)

Re: What URL is in webgadget

Posted: Tue Mar 12, 2013 6:48 pm
by Shardik
Since the navigation callback is only implemented in Windows, I have modified a nice code example from Wilbert to do the same as the example from PB help posted by Kiffi. It intercepts and denies a click onto the news hyperlink on the purebasic homepage:
http://www.purebasic.fr/english/viewtop ... 08&start=5