mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 17:39:20 +02:00
Make Cocoa NSButton text changeable
git-svn-id: trunk@43602 -
This commit is contained in:
parent
835bae06f5
commit
22f271c161
@ -923,12 +923,15 @@ end;
|
|||||||
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
class procedure TCocoaWSWinControl.SetText(const AWinControl: TWinControl; const AText: String);
|
||||||
var
|
var
|
||||||
obj: NSObject;
|
obj: NSObject;
|
||||||
|
text:string;
|
||||||
begin
|
begin
|
||||||
if not AWinControl.HandleAllocated then
|
if not AWinControl.HandleAllocated then
|
||||||
Exit;
|
Exit;
|
||||||
obj := NSObject(AWinControl.Handle);
|
obj := NSObject(AWinControl.Handle);
|
||||||
|
text:=AText;
|
||||||
|
DeleteAmpersands(text);
|
||||||
if obj.isKindOfClass_(NSControl) then
|
if obj.isKindOfClass_(NSControl) then
|
||||||
SetNSControlValue(NSControl(obj), AText);
|
SetNSControlValue(NSControl(obj), text);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class function TCocoaWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
class function TCocoaWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
||||||
|
@ -154,6 +154,7 @@ type
|
|||||||
published
|
published
|
||||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||||
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
|
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
|
||||||
|
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TLCLCheckBoxCallback }
|
{ TLCLCheckBoxCallback }
|
||||||
@ -243,13 +244,17 @@ const
|
|||||||
|
|
||||||
function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButtonCallBackClass; const AParams: TCreateParams; btnBezel: NSBezelStyle; btnType: NSButtonType): NSButton;
|
function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButtonCallBackClass; const AParams: TCreateParams; btnBezel: NSBezelStyle; btnType: NSButtonType): NSButton;
|
||||||
var
|
var
|
||||||
|
titel:string;
|
||||||
cap: NSString;
|
cap: NSString;
|
||||||
begin
|
begin
|
||||||
Result := TCocoaButton.alloc.lclInitWithCreateParams(AParams);
|
Result := TCocoaButton.alloc.lclInitWithCreateParams(AParams);
|
||||||
if Assigned(Result) then
|
if Assigned(Result) then
|
||||||
begin
|
begin
|
||||||
TCocoaButton(Result).callback := ACallBackClass.Create(Result, ATarget);
|
TCocoaButton(Result).callback := ACallBackClass.Create(Result, ATarget);
|
||||||
cap := NSStringUTF8(AParams.Caption);
|
titel:=aParams.Caption;
|
||||||
|
DeleteAmpersands(titel);
|
||||||
|
cap := NSStringUTF8(titel);
|
||||||
|
|
||||||
Result.setTitle(cap);
|
Result.setTitle(cap);
|
||||||
cap.release;
|
cap.release;
|
||||||
if btnBezel <> 0 then
|
if btnBezel <> 0 then
|
||||||
@ -382,6 +387,19 @@ begin
|
|||||||
cf.release;
|
cf.release;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
class procedure TCocoaWSButton.SetText(const AWinControl: TWinControl; const AText: String);
|
||||||
|
var
|
||||||
|
titel:string;
|
||||||
|
cap: NSString;
|
||||||
|
begin
|
||||||
|
titel:=AText;
|
||||||
|
DeleteAmpersands(titel);
|
||||||
|
cap := NSStringUTF8(titel);
|
||||||
|
NSButton(AWinControl.Handle).setTitle(cap);
|
||||||
|
cap.release;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TCocoaWSCustomCheckBox }
|
{ TCocoaWSCustomCheckBox }
|
||||||
|
|
||||||
{------------------------------------------------------------------------------
|
{------------------------------------------------------------------------------
|
||||||
|
Loading…
Reference in New Issue
Block a user