Merged revision(s) 61674 #f6181c1d0d, 61687-61688 #2a64470b79-#2a64470b79 from trunk:

cocoa: ultimate fix for modal menus not making clicks. #35929
........
cocoa: notifying the tablelist about number of items changing. #35957
........
cocoa: applying resource leak patch by Zoë Peterson. #35944
........

git-svn-id: branches/fixes_2_0@61700 -
This commit is contained in:
maxim 2019-08-15 22:55:58 +00:00
parent 864f673246
commit c5febdebb9
3 changed files with 26 additions and 17 deletions

View File

@ -191,8 +191,8 @@ type
//carbon//class procedure SetHotTrackStyles(const ALV: TCustomListView; const AValue: TListHotTrackStyles); override;
//carbon//class procedure SetHoverTime(const ALV: TCustomListView; const AValue: Integer); override;
class procedure SetImageList(const ALV: TCustomListView; const {%H-}AList: TListViewImageList; const {%H-}AValue: TCustomImageListResolution); override;
(*class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
class procedure SetOwnerData(const ALV: TCustomListView; const {%H-}AValue: Boolean); override;*)
class procedure SetItemsCount(const ALV: TCustomListView; const Avalue: Integer); override;
(*class procedure SetOwnerData(const ALV: TCustomListView; const {%H-}AValue: Boolean); override;*)
class procedure SetProperty(const ALV: TCustomListView; const AProp: TListViewProperty; const AIsSet: Boolean); override;
class procedure SetProperties(const ALV: TCustomListView; const AProps: TListViewProperties); override;
class procedure SetScrollBars(const ALV: TCustomListView; const AValue: TScrollStyle); override;
@ -1432,6 +1432,16 @@ begin
lTableLV.lclSetImagesInCell(Assigned(AValue));
end;
class procedure TCocoaWSCustomListView.SetItemsCount(
const ALV: TCustomListView; const Avalue: Integer);
var
lCocoaLV: TCocoaListView;
lTableLV: TCocoaTableListView;
begin
if not CheckParams(lCocoaLV, lTableLV, ALV) then Exit;
lTableLV.noteNumberOfRowsChanged();
end;
class procedure TCocoaWSCustomListView.SetProperty(const ALV: TCustomListView;
const AProp: TListViewProperty; const AIsSet: Boolean);
var

View File

@ -269,6 +269,7 @@ begin
{$else}
AView.setHidden(false);
{$endif}
AView.release;
SetViewDefaults(Result);
if AView.isKindOfClass(TCocoaCustomControl) then
TCocoaCustomControl(AView).auxMouseByParent := true;

View File

@ -88,6 +88,7 @@ type
// is about to be activated.
procedure menuNeedsUpdate(AMenu: NSMenu); message 'menuNeedsUpdate:';
//procedure menuDidClose(AMenu: NSMenu); message 'menuDidClose:';
function worksWhenModal: LCLObjCBoolean; message 'worksWhenModal';
end;
TCocoaMenuItem_HideApp = objcclass(NSMenuItem)
@ -386,6 +387,18 @@ begin
menuItemCallback.ItemSelected;
end;
function TCocoaMenuItem.worksWhenModal: LCLObjCBoolean;
begin
// refer to NSMenuItem.target (Apple) documentation
// the method must be implemented in target and return TRUE
// otherwise it won't work for modal!
//
// The method COULD be used to protect the main menu from being clicked
// if a modal window doesn't have a menu.
// But LCL disables (is it?) the app menu manually on modal
Result := true;
end;
{ menuDidClose should not change the structure of the menu.
The restructuring is causing issues on Apple's special menus (i.e. HELP menu)
See bug #35625
@ -840,21 +853,6 @@ begin
end;
res := TCocoaMenu(APopupMenu.Handle).popUpMenuPositioningItem_atLocation_inView(
nil, NSMakePoint(px, py), view);
// for whatever reason a context menu will not fire the "action"
// of the specified target. Thus we're doing it here manually. :(
// It seems a typical behaviour for all versions of macOS
// todo: find out why. (calling runModalSession makes no difference)
if Assigned(CocoaWidgetSet.Modals) and (CocoaWidgetSet.Modals.Count>0) then
begin
mnu := TCocoaMenu(APopupMenu.Handle).highlightedItem;
if res and Assigned(mnu) then
begin
if mnu.respondsToSelector(ObjCSelector('lclItemSelected:')) then
TCocoaMenuItem(mnu).lclItemSelected(mnu);
end;
end;
APopupMenu.Close; // notify LCL popup menu
end;
end;