Re: OpenURL issue not fixed with an OpenURLService

R Frith-Macdonald <[email protected]> Mon, 8 Dec 2025 20:12:56 +0000
Newsgroups gmane.comp.lib.gnustep.general
Message-ID <[email protected]>
On 08/12/2025 18:49, Patrick Cardona wrote:
> Hello,
>
> Until now, I was not able to fix the openURL issue.
>
> Context:
> - I added a wrapper 'Firefox.app'.
> - The Default Web Browser in 'SystemPreferences > Internet' has been 
> set to Firefox.app. Its Info-gnustep.plist contains the expected array 
> 'CFBundleURLTypes'.

The default web browser is what is supposed to be used to open a URL if 
an app asks to open that URL (like asking to open a file) by calling the 
-openURL: method.

> - But the "firefox" word is not found in any .plist of 
> '~/GNUstep/Defaults' folder.

The preferred/default app for a task is stored in 
Services.GNUstepExtPrefs in the Library directory, not in the defaults 
database.


> I also installed an OpenURLService, did 'make_services' and 
> successfully tested with a selected URL string. But this is not fixing 
> the case of links within TextEdit nor GNUMail.

Services are provided by the Services menu ... typically highlighting 
text and selecting a service should perform that service on that text.

>
> 1) Without the link filter, when the string "https://www.gnustep.org" 
> is selected,
> in a text file, the menu 'Services > Open Selected URL' is available 
> and it works to open the above URL in the default browser (firefox).

So that confirms that your service is working ... you can highlight any 
text and use the Services menu to open it as a URL.

> 2) With the link filter: if I use 'Edit > Add link' menu within 
> TextEdit, the related link (same URL as above) is created and 
> highlighted (with the blue color and the expected pointer of the mouse 
> over)
> GNUstep.org
> But when I click on the above link, nothing happens.

Clicking on some general text in an app is controlled by that app (it's 
not something built into the GNUstep libraries).  If the app wants to 
open a URL in a browser, I would expect the app to call the  -openURL:  
method.   Since it seems that  -openURL: is not being called, I'd guess 
the two apps you are talking about do not want to open links when they 
are clicked.

> I guess in the case two:
> - The mouseDown Event should handle the NSURL object with the openURL 
> method.
> - Something related to default Web Browser in NSWorkspace should 
> handle both the default browser app and the openURL method.
>
> So I guess my Service menu will never be useful to handle such case, 
> because URL strings are not the same as NSURL objects.
>
> How do you handle such links? 

I think it sounds like what you want is to change TextEdit and GNUmail 
to support clicking on links in the text they are displaying to open 
aURLs.  That means they must check the mouse down, see if it was over a 
part of their text that looks like a link, and decide (according to some 
rule you decide on) whether they want to open the link rather than 
editing the text.  If they want to open the link the apps need to, call 
-openURL: passing the URL as a parameter.  I don't haver the source code 
to hand, but last time I looked TextEdit.app does not support clickable 
links, and I'm guessing GNUmail doesn't either.

The GNUstep framework provides the mechanism (call the -openURL: method, 
and it will use the preferred app to do so), but it's up to individual 
apps whether/when they use it.

The framework also provides the Services menu as a way to perform this 
(and other installed services) on any text that an app allows to be 
selected.  Service are pretty much automatically available (if an app 
prevents text from being selectable, that's generally deliberate).