Forum > Carbon

html help on Mac

(1/2) > >>

i'm trying to understand how to configure html help to work on the mac version of my app (it works fine on windows).

i'm still trying to wrap my head around how things work on the mac.

i'm using the htmlhelp1 example, calling help from the button click:

if i run the example via the lazarus IDE, no problem.

if i compile it, then run the app from Finder (or drag it to the dock), it throws up a dialog "Help context not found... was unable to find file /html/index.html".

if i run it from terminal it throws up a similar dialog: "... unable to find file /Developer/lazarus/examples/helphtml/"

if i add the html folder (and its contents) to the Contents/MacOS directory, it then runs fine from Terminal.

however, it will still does not find the help file if i run the app from Finder (or the dock).

i'd like to package the application for end users, but i can't figure out where to put the help file so the app can find it.

the wiki says 'On Unix there is no "application directory"' - so, where should i put the html help folder, and how do i tell the app where to find it?

Is anyone using help on the Mac?  If not, how do you link to your application help file?


--- Quote from: RxRick on July 21, 2010, 07:18:48 pm ---Is anyone using help on the Mac?  If not, how do you link to your application help file?

--- End quote ---
actually i go directly to using Safari

but let me look at your problem.


I tried putting the html folder in the same directory as the app bundle, in the app's bundle root, under Contents, under Contents/MacOS, under Contents/Resources, under my Users folder.

I was finally able to get it to "work" by placing the html folder in the Macintosh HD folder, but that seems extreme. would make more sense to have the help file for my app packaged in with the app bundle itself.

The problem is that LazHelpHTML component DEPENDS upon proper current directory set by the application.

Let's assume the application bundle path is: /Users/user/helphtml/

* When you start the application from the Lazarus. It's current directory is set to the directory of the bundle. (i.e. '/Users/user/helphtml'). So LazHelpHTML is able to resolve the correct path of html files: /Users/user/helphtml/HTML

* When you start the application by Finder (or from the Dock), it's current path is set to "/". What results in incorrect help file selected.

* When you start the application manually from terminal, it's current path is set to "/Users/user/helphtml/" (the directory where the executable is located). It would work correct, but only if you copy the HTML dir into the bundle path. (which is wrong).

To correct things you need to adjust the current path (to the required one) whenever the application is started. For example (htmlhelp1.lpr):

--- Code: ---program HTMLHelp1;

{$mode objfpc}{$H+}

  {$IFDEF UNIX}{$IFDEF UseCThreads}
  Interfaces, // this includes the LCL widgetset
  { add your units here }, Unit1, SysUtils, FileUtil;

procedure AdjustCurrentPath;
{$ifdef DARWIN}
  i : integer;
  path  : Ansistring;
  for i:=1 to 3 do // remove: watnedpath/ - 3 dirs
  SetCurrentDirUTF8( path );
  // do nothing if not OSX

  Application.CreateForm(TForm1, Form1);

--- End code ---

I'm not HTML help specialist, but I guess, it's possible to avoid "relative" path usage in the component.

MacOSX NOTE:Application resources should NOT be stored out-side of the bundle. Help files should be kept at: directory.

--- Code:

--- End code ---
And so current directory should be set to the bundle's resources instead.
However, the current example doesn't allow to keep HTML inside the bundle, so it's fine to change current directory to the bundle's directory, in this particular case.


[0] Message Index

[#] Next page

Go to full version