cocoa: hiding focus ring, if borderstyle is none. bug #34828

git-svn-id: trunk@62531 -
This commit is contained in:
dmitry 2020-01-12 01:06:54 +00:00
parent 98c349fc08
commit 35bf1396b2
5 changed files with 23 additions and 0 deletions

View File

@ -245,6 +245,8 @@ var
CocoaToggleBezel : NSBezelStyle = NSRoundedBezelStyle;
CocoaToggleType : NSButtonType = NSPushOnPushOffButton;
CocoaHideFocusNoBorder : Boolean = true;
{$ifdef COCOALOOPHIJACK}
// The flag is set to true once hi-jacked loop is finished (at the end of app)
// The flag is checked in Menus to avoid "double" Cmd+Q menu

View File

@ -244,6 +244,7 @@ begin
scroll.setAutohidesScrollers(true);
ScrollViewSetBorderStyle(scroll, TCustomCheckListBox(AWinControl).BorderStyle);
UpdateFocusRing(list, TCustomCheckListBox(AWinControl).BorderStyle);
Result := TLCLIntfHandle(scroll);
end;

View File

@ -1027,6 +1027,7 @@ begin
lCocoaLV.callback := lclcb;
ScrollViewSetBorderStyle(lCocoaLV, TCustomListView(AWinControl).BorderStyle);
UpdateFocusRing(lTableLV, TCustomListView(AWinControl).BorderStyle);
{$IFDEF COCOA_DEBUG_LISTVIEW}
WriteLn(Format('[TCocoaWSCustomListView.CreateHandle] headerView=%d', [PtrInt(lTableLV.headerView)]));
@ -1039,6 +1040,7 @@ class procedure TCocoaWSCustomListView.SetBorderStyle(
begin
if not Assigned(AWinControl) or not AWinControl.HandleAllocated then Exit;
ScrollViewSetBorderStyle(NSScrollView(AWinControl.Handle), ABorderStyle);
UpdateFocusRing(NSView(NSScrollView(AWinControl.Handle).documentView), ABorderStyle);
end;
class procedure TCocoaWSCustomListView.ColumnDelete(const ALV: TCustomListView;

View File

@ -160,6 +160,7 @@ function EmbedInManualScrollHost(AView: TCocoaManualScrollView): TCocoaManualScr
function HWNDToTargetObject(AFormHandle: HWND): TObject;
procedure ScrollViewSetBorderStyle(sv: NSScrollView; astyle: TBorderStyle);
procedure UpdateFocusRing(v: NSView; astyle: TBorderStyle);
function ButtonStateToShiftState(BtnState: PtrUInt): TShiftState;
function CocoaModifiersToKeyState(AModifiers: NSUInteger): PtrInt;
@ -218,6 +219,17 @@ begin
sv.setBorderType( NSBorderStyle[astyle] );
end;
procedure UpdateFocusRing(v: NSView; astyle: TBorderStyle);
const
NSFocusRing : array [TBorderStyle] of NSBorderType = (
NSFocusRingTypeNone, // bsNone
NSFocusRingTypeDefault // bsSingle s
);
begin
if Assigned(v) and CocoaHideFocusNoBorder then
v.setFocusRingType( NSFocusRing[astyle] );
end;
function EmbedInScrollView(AView: NSView; AReleaseView: Boolean): TCocoaScrollView;
var
r: TRect;

View File

@ -943,6 +943,7 @@ begin
end;
TextFieldSetAllignment(field, TCustomEdit(AWinControl).Alignment);
TextFieldSetBorderStyle(field, TCustomEdit(AWinControl).BorderStyle);
UpdateFocusRing(field, TCustomEdit(AWinControl).BorderStyle);
Result:=TLCLIntfHandle(field);
end;
@ -969,6 +970,7 @@ begin
if not Assigned(field) then Exit;
field.setBordered_( ObjCBool(ABorderStyle <> bsNone) );
field.setBezeled_( ObjCBool(ABorderStyle <> bsNone) );
UpdateFocusRing(field, ABorderStyle);
end;
class function TCocoaWSCustomEdit.GetSelStart(const ACustomEdit: TCustomEdit): integer;
@ -1440,6 +1442,7 @@ begin
scr.setDrawsBackground(false);
ScrollViewSetBorderStyle(scr, TCustomMemo(AWinControl).BorderStyle);
UpdateFocusRing(txt, TCustomMemo(AWinControl).BorderStyle);
nr:=scr.documentVisibleRect;
txt.setFrame(nr);
@ -1531,6 +1534,7 @@ begin
if not Assigned(sv) then Exit;
ScrollViewSetBorderStyle(sv, ABorderStyle);
UpdateFocusRing(NSView(sv.documentView), ABorderStyle);
end;
class function TCocoaWSCustomMemo.GetCaretPos(const ACustomEdit: TCustomEdit): TPoint;
@ -2086,6 +2090,7 @@ begin
scroll.setHasVerticalScroller(true);
scroll.setAutohidesScrollers(true);
ScrollViewSetBorderStyle(scroll, lclListBox.BorderStyle);
UpdateFocusRing(list, lclListBox.BorderStyle);
Result := TLCLIntfHandle(scroll);
end;
@ -2198,6 +2203,7 @@ begin
if not Assigned(list) then Exit;
ScrollViewSetBorderStyle(list.enclosingScrollView, ABorderStyle);
UpdateFocusRing(list, ABorderStyle);
end;
class procedure TCocoaWSCustomListBox.SetItemIndex(const ACustomListBox: TCustomListBox; const AIndex: integer);