Dear all,
I am using THistoryFiles (
http://wiki.freepascal.org/HistoryFiles) in a project running on linux/win/osx.
I have an issue with THistoryFiles on Carbon.
Specifically, the issue is related to historyfiles.pas when clicking on a recent menu item.
When a recent menu item is clicked an event is raised in HistoryFiles:
procedure THistoryFiles.OnMainMenuClickHistoryItem(Sender:TObject);
var
thefile : string;
begin
thefile:='';
If Assigned(FOnHistoryItemClick) Then
begin
thefile := FItems.Strings[TMenuItem(sender).tag-1];
if thefile<>'' then
FLastItemIndex := TMenuItem(sender).tag;
LastItemIndex_WriteIni;
FOnHistoryItemClick(Self, TMenuItem(sender), thefile);
UpdateParentMenu;
end;
end;
Before the event is raised the following function is executed (in carbonobject.inc)
function CarbonApp_CommandProcess(ANextHandler: EventHandlerCallRef;
AEvent: EventRef;
{%H-}AWidget: TCarbonWidget): OSStatus; {$IFDEF darwin}mwpascal;{$ENDIF}
Staring from line 271 the following code is executed:
if CarbonMenu.Parent.Dismissed=kHIMenuDismissedBySelection then begin
FillChar(Msg{%H-}, SizeOf(Msg), 0);
Msg.msg := LM_ACTIVATE;
DeliverMessage(CarbonMenu.LCLMenuItem, Msg);
if assigned(CarbonMenu.Parent) then // if parent not closed
CarbonMenu.Parent.Dismissed:=0;
Result := noErr;
Exit;
end else
Result:=CallNextEventHandler(ANextHandler, AEvent);
Specifically THistoryFiles.OnMainMenuClickHistoryItem is executed on DeliverMessage, the issue is that in THistoryFiles.OnMainMenuClickHistoryItem the menu is deleted and replaced by thistoryfiles, so when executing the instructions after DeliverMessage the CarbonMenu does not exists anymore.
Any hint?
Andrea Mauri