diff --git a/lcl/interfaces/cocoa/cocoaconst.pas b/lcl/interfaces/cocoa/cocoaconst.pas index 070de7cea3..1a86ff84ec 100644 --- a/lcl/interfaces/cocoa/cocoaconst.pas +++ b/lcl/interfaces/cocoa/cocoaconst.pas @@ -28,6 +28,8 @@ const {$endif} var + NSSTR_EMPTY: NSString; + NSSTR_DARK_NAME: NSString; NSSTR_DARK_NAME_VIBRANT: NSString; @@ -36,6 +38,7 @@ var NSSTR_LINE_SEPARATOR: NSString; NSSTR_PARAGRAPH_SEPARATOR: NSString; + NSSTR_KEY_ESC: NSString; NSSTR_KEY_EQUALS: NSString; NSSTR_KEY_PLUS: NSString; @@ -49,14 +52,17 @@ const DarkNameVibrant = 'NSAppearanceNameVibrantDark'; // used in 10.13 initialization + NSSTR_EMPTY:= NSString.string_; + NSSTR_DARK_NAME:= NSSTR(DarkName); NSSTR_DARK_NAME_VIBRANT:= NSSTR(DarkNameVibrant); - NSSTR_LINE_FEED:= NSStr(#10); - NSSTR_CARRIAGE_RETURN:= NSStr(#13); + NSSTR_LINE_FEED:= NSSTR(#10); + NSSTR_CARRIAGE_RETURN:= NSSTR(#13); NSSTR_LINE_SEPARATOR:= NSString.alloc.initWithUTF8String(#$E2#$80#$A8); NSSTR_PARAGRAPH_SEPARATOR:= NSString.alloc.initWithUTF8String(#$E2#$80#$A9); + NSSTR_KEY_ESC:= NSSTR(#27); NSSTR_KEY_EQUALS:= NSSTR('='); NSSTR_KEY_PLUS:= NSSTR('+'); diff --git a/lcl/interfaces/cocoa/cocoalclintf.inc b/lcl/interfaces/cocoa/cocoalclintf.inc index eb770c636e..ca4353bcda 100644 --- a/lcl/interfaces/cocoa/cocoalclintf.inc +++ b/lcl/interfaces/cocoa/cocoalclintf.inc @@ -290,16 +290,16 @@ begin aButton.setKeyEquivalentModifierMask(0); if I = DefaultIndex then - aButton.setKeyEquivalent(NSSTR(#13)) + aButton.setKeyEquivalent(NSSTR_KEY_ESC) else if I = 0 then // By default, the first button is the default button. If in our // case this should not be the case, remove the default status // from the first button. - aButton.setKeyEquivalent(NSSTR('')); + aButton.setKeyEquivalent(NSSTR_EMPTY); if Buttons[I]=mrCancel then begin needsCancel := False; - aButton.setKeyEquivalent(NSSTR(#27)); + aButton.setKeyEquivalent(NSSTR_KEY_ESC); end; aButton.setTag(Buttons[I]); diff --git a/lcl/interfaces/cocoa/cocoatables.pas b/lcl/interfaces/cocoa/cocoatables.pas index 82d44d3044..f410546b43 100644 --- a/lcl/interfaces/cocoa/cocoatables.pas +++ b/lcl/interfaces/cocoa/cocoatables.pas @@ -29,7 +29,7 @@ uses Types, Classes, SysUtils, // Libs MacOSAll, CocoaAll, CocoaUtils, CocoaGDIObjects, - cocoa_extra, CocoaPrivate, + cocoa_extra, CocoaPrivate, CocoaConst, // LCL LCLType; @@ -924,7 +924,7 @@ begin if not isFirstColumnCheckboxes and isImagesInCell then begin img := lclGetItemImageAt(row, col); - Result := NSImageAndTextCell(NSImageAndTextCell.alloc).initTextCell(NSSTR('')); + Result := NSImageAndTextCell(NSImageAndTextCell.alloc).initTextCell(NSSTR_EMPTY); NSImageAndTextCell(Result).drawImage := img; // if "image" is assigned, text won't be drawn :( Exit; end; diff --git a/lcl/interfaces/cocoa/cocoathemes.pas b/lcl/interfaces/cocoa/cocoathemes.pas index 3d90198af8..312a2bd2f1 100644 --- a/lcl/interfaces/cocoa/cocoathemes.pas +++ b/lcl/interfaces/cocoa/cocoathemes.pas @@ -22,7 +22,7 @@ uses LCLType, LCLProc, LCLIntf, Graphics, Themes, TmSchema, customdrawndrawers, // widgetset - CocoaUtils, CocoaGDIObjects; + CocoaUtils, CocoaGDIObjects, CocoaConst; type { TCocoaThemeServices } @@ -266,7 +266,7 @@ var begin if (HdrCell=nil) then begin - hdrCell := NSTableHeaderCell.alloc.initTextCell(NSSTR('')); + hdrCell := NSTableHeaderCell.alloc.initTextCell(NSSTR_EMPTY); end; CellDrawStart(DC, R, cur, nsr); @@ -530,7 +530,7 @@ begin end; if cocoaBtn < 0 then Exit; // unsupported button type - btn := NSButtonCell(NSButtonCell.alloc).initTextCell(NSSTR('')); + btn := NSButtonCell(NSButtonCell.alloc).initTextCell(NSSTR_EMPTY); btn.setButtonType(NSButtonType(cocoaBtn)); SetButtonCellToDetails(btn, Details); @@ -542,7 +542,7 @@ end; constructor TCocoaThemeServices.Create; begin inherited Create; - BtnCell := NSButtonCell.alloc.initTextCell(NSSTR('')); + BtnCell := NSButtonCell.alloc.initTextCell(NSSTR_EMPTY); BezelToolBar := NSSmallSquareBezelStyle; // can be resized at any size BezelButton := NSSmallSquareBezelStyle; diff --git a/lcl/interfaces/cocoa/cocoawsstdctrls.pas b/lcl/interfaces/cocoa/cocoawsstdctrls.pas index 5a7e9c27fa..31729ac279 100644 --- a/lcl/interfaces/cocoa/cocoawsstdctrls.pas +++ b/lcl/interfaces/cocoa/cocoawsstdctrls.pas @@ -1432,8 +1432,6 @@ var ns : NSString; idx : integer; ro : Boolean; -const - LFSTR = #10; begin ns:=FTextView.string_; idx:=0; @@ -1455,7 +1453,7 @@ begin FTextView.setSelectedRange(rng); if (rng.location>=ns.length) and (st=ced) and (ns.length>0) then - FTextView.insertText( NSString.stringWithUTF8String( LFSTR )); + FTextView.insertText( NSSTR_LINE_FEED ); if S<>'' then begin @@ -1463,7 +1461,7 @@ begin end; dec(FTextView.supressTextChangeEvent); - FTextView.insertText( NSString.stringWithUTF8String( LFSTR )); + FTextView.insertText( NSSTR_LINE_FEED ); if not ro then FTextView.setEditable(ro);