Murga-Projects Forums
Browser Interaction with URLs - Printable Version

+- Murga-Projects Forums (
+-- Forum: Project Forums (/forumdisplay.php?fid=1)
+--- Forum: MurgaLua - General (/forumdisplay.php?fid=2)
+--- Thread: Browser Interaction with URLs (/showthread.php?tid=113)

Browser Interaction with URLs - iGame3D - 07-16-2007 08:35 PM

How best to handle a URL in murgaLua?

For instance if you want to send a user to a webpage by calling up their browser.

Also how to display an item of text as a hot link?

RE: Browser Interaction with URLs - mikshaw - 07-17-2007 01:13 AM

I don't know about the "best" way, but I would recommend using os.execute() along with a user-defined variable. If the variable is nil, or is set incorrectly, inform the user that it needs to be changed. I've seen some applications attempt to automatically detect what browser the user will likely be using, and it seemed ridiculous to put that much time, effort, and bloat into something that will never be completely reliable. The most reasonable ones, in my opinion, simply use a common browser as the default and allow the user to change it easily, via enviroment variable or configuration file, for example.

I had thought about a similar thing a few days ago, using local paths, but never figured out how to get a specific piece of text hot. I guess you might be able to position a button over the appropriate part of the text, but I couldn't say how difficult that might be, particularly with varying font sizes/spacing.

There is the Fl_Help_View class, which displays full pages of HTML, but I'm guessing this would probably not apply to your situation. It might provide some hint to using URLs with other widgets, though.

There's also the possibility of breaking your text up into multiple (flat) buttons in a visual array, activating only the button(s) that are labeled with the hot text. This will likely produce unappealing breaks between sentence fragments, though, and is probably not a good solution.

There could be something that could be used in relation to drawing text, but that subject is over my head.

Maybe creating a new subclass of Fl_Widget including a specific focus box could be the answer. Again, this subject is beyond my abilities.

I know this is not much help, but may give some ideas about where to look for other possibile solutions.

RE: Browser Interaction with URLs - JohnMurga - 07-17-2007 02:51 AM


They have something like that in ... I think.


RE: Browser Interaction with URLs - iGame3D - 07-17-2007 02:16 PM

Ok I'll take it for now we don't have a way to do that out of the box.

I was contemplating access to the lua functions, c api and auxillary
library documentation links inside of an FLTK interface.
It can be achieved by other means for now.

RE: Browser Interaction with URLs - mikshaw - 07-25-2007 09:29 AM

You might want to look at fl_open_uri()

It apparently uses system default web browser, mail reader, or file manager, depending on the protocol. I have no system default applications (to my knowledge) so I have no way to test it unless I go find out whether or not I can set these defaults when I don't use a desktop environment.

I assume it should at least work on Windows, probably Mac, and *maybe* on a Linux distro such as Ubuntu that has lots of these default thingies preset.

RE: Browser Interaction with URLs - iGame3D - 07-25-2007 09:57 AM

Doesn't seem to work. But then maybe I'm using it wrong, can't make head or tails of what a command expects from the FLTK docs.

fl_open_uri(const char *uri, char *msg = (char *)0, int msglen = 0);

tried somethings that I expected to work but I get a nil value error.

RE: Browser Interaction with URLs - mikshaw - 07-25-2007 01:44 PM

FLTK functions in murgaLua must be called with "fltk.<function>". Otherwise you'll get a nil value.
This is what I did:


and got my local server loaded in Firefox. The "file" protocol did not work for me.

The second and third arguments are optional, and trying those didn't seem to make any difference for me. As I said before, my problem is most likely that my system does not have a default file manager and I haven't got a clue how to configure it outside of a specific desktop environment. For now I'm just pleased that it at least works for the http protocol.

UPDATE: Apparently the http protocol only works for me if I already have Firefox opened. I'm guessing it's using "firefox-remote" (or "mozilla"?) rather than "firefox".

RE: Browser Interaction with URLs - iGame3D - 07-25-2007 04:02 PM

Excellent. that worked like a charm.

The file structure works a bit different than a web address, has an extra slash


RE: Browser Interaction with URLs - mikshaw - 07-27-2007 12:11 AM

Tested successfully in Windows XP Home, although Windows has yet another silly issue. File paths that include spaces will not work simply by enclosing the string in quotes. The spaces themselves must be escaped or converted to %20. So now code is needed for both the backslash and the spaces.

That took too long for me to figure out...quotes seem to have been sufficient up to this point, so I didn't think it would be necessessary.

Now that I think about it more, though, I haven't yet tested this on filenames with spaces in Linux either. As far as I know, the quotes might not work here either.

RE: Browser Interaction with URLs - iGame3D - 07-27-2007 10:19 AM

That "%20" rubbish has irritated me for a decade now.

Apparently the issue exists on the Mac as well.

fltk.fl_open_uri("file:///ig3d_mac_xcode/Data/Levels/SquigLand/load\ script.txt")

Doesn't work


Does work.

I suppose its the price we pay for "universal resource".