It is currently Mon Dec 17, 2018 12:00 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Mac WebGadget callback ?
PostPosted: Fri Jul 10, 2015 1:05 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1574
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:
  ; 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!


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac WebGadget callback ?
PostPosted: Fri Jul 10, 2015 7:38 am 
Offline
Addict
Addict
User avatar

Joined: Thu Apr 21, 2005 2:38 pm
Posts: 1574
Location: Germany
Did you already take a look into my navigation callback example for MacOS?

I also demonstrated here how to do it in Linux.


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac WebGadget callback ?
PostPosted: Fri Jul 10, 2015 1:18 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1574
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).


Top
 Profile  
Reply with quote  
 Post subject: Re: Mac WebGadget callback ?
PostPosted: Sat Jul 11, 2015 4:51 am 
Offline
Addict
Addict
User avatar

Joined: Tue Dec 23, 2003 3:54 am
Posts: 1574
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...


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

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 4 guests


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