It is currently Sun Dec 16, 2018 6:25 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 7 posts ] 
Author Message
 Post subject: WebGadget help example with nav-callback...
PostPosted: Tue Mar 12, 2013 11:37 am 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1206
Location: germany
Hello,

the Example 2: (with navigation callback) from the WebGadget help page does not work:

Code:
Procedure NavigationCallback(Gadget, Url$)
  If Url$= "http://www.purebasic.com/news.php"
    MessageRequester("", "No news today!")
    ProcedureReturn #False
  Else
    ProcedureReturn #True
  EndIf
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


There is nothing mentioned that this is not working on MacOS - so it is a bug?

Kukulkan


Last edited by Kukulkan on Tue Mar 12, 2013 5:53 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: WebGadget help example with nav-callback does not work
PostPosted: Tue Mar 12, 2013 1:22 pm 
Offline
Enthusiast
Enthusiast

Joined: Mon Feb 16, 2009 10:42 am
Posts: 536
Location: sweden
I had that in a previous post. The callback doesn't work for webgadget for mac. no bug - its just not implemented.
You can check page by in the main loop do a getgadgettext(gadget) to see if it has changed.


Top
 Profile  
Reply with quote  
 Post subject: Re: WebGadget help example with nav-callback does not work
PostPosted: Tue Mar 12, 2013 1:30 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1206
Location: germany
Hi,

in this case the bug is in the documentation. There is nothing mentioned that this is not working on MacOS.

Kukulkan


Top
 Profile  
Reply with quote  
 Post subject: Re: WebGadget help example with nav-callback does not work
PostPosted: Tue Mar 12, 2013 5:31 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1571
Location: Germany
Kukulkan wrote:
in this case the bug is in the documentation. There is nothing mentioned that this is not working on MacOS.

PB help for WebGadget wrote:
- SetGadgetAttribute(): Set the following attributes (Windows only):


Top
 Profile  
Reply with quote  
 Post subject: Re: WebGadget help example with nav-callback does not work
PostPosted: Tue Mar 12, 2013 5:53 pm 
Offline
Addict
Addict
User avatar

Joined: Mon Jun 06, 2005 2:35 pm
Posts: 1206
Location: germany
Oh damn :oops: Sorry.


Top
 Profile  
Reply with quote  
 Post subject: Re: [DONE]WebGadget help example with nav-callback does not
PostPosted: Tue Mar 12, 2013 6:14 pm 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1571
Location: Germany
Since SetGadgetAttribute() is not implemented on MacOS X, you may use the following modified code taken from wilbert's nice example to intercept clicks on a hyperlink just as in the example from PB help:
Code:
EnableExplicit

ImportC ""
  sel_registerName(str.p-ascii)
  class_addMethod(class, selector, imp, types.p-ascii)
EndImport

Global appDelegate = CocoaMessage(0, CocoaMessage(0, 0, "NSApplication sharedApplication"), "delegate")
Global delegateClass = CocoaMessage(0, appDelegate, "class")

ProcedureC PolicyDecisionMaker(obj, sel, webView, actionInformation, request, frameName, listener)
  Protected URL = CocoaMessage(0, request, "URL")
  Protected URLString.s = PeekS(CocoaMessage(0, CocoaMessage(0, URL, "absoluteString"), "UTF8String"), -1, #PB_UTF8)

  If URLString = "http://www.purebasic.com/news.php"
    MessageRequester("", "No news today!")
  Else
    CocoaMessage(0, listener, "use")
  EndIf
EndProcedure

class_addMethod(delegateClass, sel_registerName("webView:decidePolicyForNavigationAction:request:frame:decisionListener:"), @PolicyDecisionMaker(), "v@:@@@@@")

If OpenWindow(0, 270, 100, 600, 300, "WebGadget")
  WebGadget(0, 10, 10, 580, 280, "http://www.purebasic.com")
  CocoaMessage(0, GadgetID(0), "setPolicyDelegate:", appDelegate)
 
  Repeat
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf

It would be nice if this thread could be moved to the MacOSX subforum.


Top
 Profile  
Reply with quote  
 Post subject: Re: [DONE]WebGadget help example with nav-callback does not
PostPosted: Tue Mar 19, 2013 11:47 pm 
Offline
PureBasic Team
PureBasic Team
User avatar

Joined: Fri Apr 25, 2003 6:14 pm
Posts: 1610
Location: Germany (Saxony, Deutscheinsiedel)
I moved this topic from bug-reports to regular MacOS forum for further use, and additionally changed the thread title a bit... :-)

_________________
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 7 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye