mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-17 05:49:23 +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);
|
||||
var
|
||||
obj: NSObject;
|
||||
text:string;
|
||||
begin
|
||||
if not AWinControl.HandleAllocated then
|
||||
Exit;
|
||||
obj := NSObject(AWinControl.Handle);
|
||||
text:=AText;
|
||||
DeleteAmpersands(text);
|
||||
if obj.isKindOfClass_(NSControl) then
|
||||
SetNSControlValue(NSControl(obj), AText);
|
||||
SetNSControlValue(NSControl(obj), text);
|
||||
end;
|
||||
|
||||
class function TCocoaWSWinControl.GetText(const AWinControl: TWinControl; var AText: String): Boolean;
|
||||
|
@ -154,6 +154,7 @@ type
|
||||
published
|
||||
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
|
||||
class procedure SetDefault(const AButton: TCustomButton; ADefault: Boolean); override;
|
||||
class procedure SetText(const AWinControl: TWinControl; const AText: String); override;
|
||||
end;
|
||||
|
||||
{ TLCLCheckBoxCallback }
|
||||
@ -243,13 +244,17 @@ const
|
||||
|
||||
function AllocButton(const ATarget: TWinControl; const ACallBackClass: TLCLButtonCallBackClass; const AParams: TCreateParams; btnBezel: NSBezelStyle; btnType: NSButtonType): NSButton;
|
||||
var
|
||||
titel:string;
|
||||
cap: NSString;
|
||||
begin
|
||||
Result := TCocoaButton.alloc.lclInitWithCreateParams(AParams);
|
||||
if Assigned(Result) then
|
||||
begin
|
||||
TCocoaButton(Result).callback := ACallBackClass.Create(Result, ATarget);
|
||||
cap := NSStringUTF8(AParams.Caption);
|
||||
titel:=aParams.Caption;
|
||||
DeleteAmpersands(titel);
|
||||
cap := NSStringUTF8(titel);
|
||||
|
||||
Result.setTitle(cap);
|
||||
cap.release;
|
||||
if btnBezel <> 0 then
|
||||
@ -382,6 +387,19 @@ begin
|
||||
cf.release;
|
||||
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 }
|
||||
|
||||
{------------------------------------------------------------------------------
|
||||
|
Loading…
Reference in New Issue
Block a user