Commit 35bf1396 authored by dmitry's avatar dmitry
Browse files

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

git-svn-id: trunk@62531 -
parent 98c349fc
......@@ -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
......
......@@ -244,6 +244,7 @@ begin
scroll.setAutohidesScrollers(true);
ScrollViewSetBorderStyle(scroll, TCustomCheckListBox(AWinControl).BorderStyle);
UpdateFocusRing(list, TCustomCheckListBox(AWinControl).BorderStyle);
Result := TLCLIntfHandle(scroll);
end;
......
......@@ -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;
......
......@@ -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;
......
......@@ -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);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment