mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-24 12:39:23 +02:00
Cocoa: remove the acceleration in Menu/Tab title, make it consistent with macOS idioms
This commit is contained in:
parent
2fbdd4de2f
commit
1adfc7d4a3
@ -68,6 +68,7 @@ function StrToNSStr(const s: string; AutoRelease: Boolean = true): NSString; inl
|
|||||||
function NSStringToString(ns: NSString): String;
|
function NSStringToString(ns: NSString): String;
|
||||||
|
|
||||||
function NSStringRemoveLineBreak(const str: NSString): NSString;
|
function NSStringRemoveLineBreak(const str: NSString): NSString;
|
||||||
|
function StringRemoveAcceleration(const str: String): String;
|
||||||
|
|
||||||
function GetNSObjectWindow(obj: NSObject): NSWindow;
|
function GetNSObjectWindow(obj: NSObject): NSWindow;
|
||||||
|
|
||||||
@ -127,9 +128,9 @@ function GetMacOSXVersion: Integer;
|
|||||||
function DateTimeToNSDate(const aDateTime : TDateTime): NSDate;
|
function DateTimeToNSDate(const aDateTime : TDateTime): NSDate;
|
||||||
function NSDateToDateTime(const aDateTime: NSDate): TDateTime;
|
function NSDateToDateTime(const aDateTime: NSDate): TDateTime;
|
||||||
|
|
||||||
// The function removes single & and replaced && with &
|
// The function removes single '&' and '(...)', and replaced '&&' with '&'
|
||||||
// (removing LCL (Windows) specific caption convention
|
// (removing LCL (Windows) specific caption convention
|
||||||
function ControlTitleToStr(const ATitle: string): String;
|
function ControlTitleToStr(const ATitle: string): String; inline;
|
||||||
// The returned NSString doesn't require a release
|
// The returned NSString doesn't require a release
|
||||||
// (it would happen in NSAutoRelease pool)
|
// (it would happen in NSAutoRelease pool)
|
||||||
function ControlTitleToNSStr(const ATitle: string): NSString;
|
function ControlTitleToNSStr(const ATitle: string): NSString;
|
||||||
@ -936,6 +937,28 @@ begin
|
|||||||
Result:= Result.stringByReplacingOccurrencesOfString_withString( NSSTR_PARAGRAPH_SEPARATOR, NSString.string_ );
|
Result:= Result.stringByReplacingOccurrencesOfString_withString( NSSTR_PARAGRAPH_SEPARATOR, NSString.string_ );
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function StringRemoveAcceleration(const str: String): String;
|
||||||
|
var
|
||||||
|
posAmp: Integer;
|
||||||
|
posRight: Integer;
|
||||||
|
posLeft: Integer;
|
||||||
|
begin
|
||||||
|
Result:= str;
|
||||||
|
posAmp:= DeleteAmpersands(Result);
|
||||||
|
if posAmp < 0 then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
posRight:= str.IndexOf( ')' );
|
||||||
|
if (posRight<0) or (posRight<posAmp) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
posLeft:= str.IndexOf( '(' );
|
||||||
|
if (posLeft<0) or (posLeft>posAmp) then
|
||||||
|
Exit;
|
||||||
|
|
||||||
|
Result:= str.Substring(0,posLeft).Trim;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure SetNSText(text: NSText; const s: String); inline;
|
procedure SetNSText(text: NSText; const s: String); inline;
|
||||||
var
|
var
|
||||||
ns: NSString;
|
ns: NSString;
|
||||||
@ -1265,8 +1288,7 @@ end;
|
|||||||
|
|
||||||
function ControlTitleToStr(const ATitle: string): String;
|
function ControlTitleToStr(const ATitle: string): String;
|
||||||
begin
|
begin
|
||||||
Result := ATitle;
|
Result:= StringRemoveAcceleration(ATitle);
|
||||||
DeleteAmpersands(Result);
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function ControlTitleToNSStr(const ATitle: string): NSString;
|
function ControlTitleToNSStr(const ATitle: string): NSString;
|
||||||
|
Loading…
Reference in New Issue
Block a user