Mac WebGadget callback ?

Mac OSX specific forum
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Mac WebGadget callback ?

Post by kenmo »

The WebGadget "navigation callback" only works on Windows (see example below) despite the #PB_Web_NavigationCallback constant being present on Mac OS X.

Is there any CocoaMessage magic I could possibly use to intercept/prevent WebGadget navigation when the user clicks a link?

Code: Select all

  ; This example does display the PureBasic.com website. Inside the callback procedure
  ; the navigation to the 'News' site will be avoided (#False returned), but allowed
  ; for all other sites (#True returned).    
  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

I am looking to intercept links to certain filetypes and open them in a different part of my program.

Thanks!
User avatar
Shardik
Addict
Addict
Posts: 1991
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Re: Mac WebGadget callback ?

Post by Shardik »

Did you already take a look into my navigation callback example for MacOS?

I also demonstrated here how to do it in Linux.
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Mac WebGadget callback ?

Post by kenmo »

Hello Shardik!

No I did not see that post. I will try it on my Mac tonight. Thank you!

I did some forum searches and did not find anything... but now I realize I should have checked the big list of Cocoa tips... or Google search (your posts are the top results).
User avatar
kenmo
Addict
Addict
Posts: 1967
Joined: Tue Dec 23, 2003 3:54 am

Re: Mac WebGadget callback ?

Post by kenmo »

Your solution seems to work perfectly! Thank you!

My only remaining Mac WebGadget issue is unrelated to this thread: the cursor icon seems unreliable. Sometimes when hovering over links it shows the "pointing finger" icon (correct) but often it shows the "I-beam" text cursor (incorrect). If I can reproduce this issue in a small example code, I might post a bug report...
Post Reply