mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 10:19:36 +02:00
Merged revision(s) 62557 #36ff050ad7 from trunk:
cocoa: fix setting a new state for cocoa checkbox. ........ git-svn-id: branches/fixes_2_0@62558 -
This commit is contained in:
parent
36b9cd3dbc
commit
b25c8c2021
@ -329,7 +329,8 @@ procedure TextViewSetAllignment(txt: NSTextView; align: TAlignment);
|
|||||||
procedure TextFieldSetAllignment(txt: NSTextField; align: TAlignment);
|
procedure TextFieldSetAllignment(txt: NSTextField; align: TAlignment);
|
||||||
procedure TextFieldSetBorderStyle(txt: NSTextField; astyle: TBorderStyle);
|
procedure TextFieldSetBorderStyle(txt: NSTextField; astyle: TBorderStyle);
|
||||||
procedure RadioButtonSwitchSiblings(checkedRadio: NSButton);
|
procedure RadioButtonSwitchSiblings(checkedRadio: NSButton);
|
||||||
procedure ButtonSetState(btn: NSButton; NewState: TCheckBoxState);
|
procedure ButtonSetState(btn: NSButton; NewState: TCheckBoxState;
|
||||||
|
SkipChangeEvent: Boolean = true);
|
||||||
|
|
||||||
procedure ScrollViewSetScrollStyles(AScroll: TCocoaScrollView; AStyles: TScrollStyle);
|
procedure ScrollViewSetScrollStyles(AScroll: TCocoaScrollView; AStyles: TScrollStyle);
|
||||||
|
|
||||||
@ -448,10 +449,13 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ButtonSetState(btn: NSButton; NewState: TCheckBoxState);
|
procedure ButtonSetState(btn: NSButton; NewState: TCheckBoxState;
|
||||||
|
SkipChangeEvent: Boolean = true);
|
||||||
const
|
const
|
||||||
buttonState: array [TcheckBoxState] of NSInteger =
|
buttonState: array [TcheckBoxState] of NSInteger =
|
||||||
(NSOffState, NSOnState, NSMixedState);
|
(NSOffState, NSOnState, NSMixedState);
|
||||||
|
var
|
||||||
|
cb : IButtonCallback;
|
||||||
begin
|
begin
|
||||||
if NewState = cbGrayed then
|
if NewState = cbGrayed then
|
||||||
{$ifdef BOOLFIX}
|
{$ifdef BOOLFIX}
|
||||||
@ -459,7 +463,18 @@ begin
|
|||||||
{$else}
|
{$else}
|
||||||
btn.setAllowsMixedState(true);
|
btn.setAllowsMixedState(true);
|
||||||
{$endif}
|
{$endif}
|
||||||
btn.setState(buttonState[NewState]);
|
if SkipChangeEvent and (btn.isKindOfClass(TCocoaButton)) then
|
||||||
|
begin
|
||||||
|
//todo: This place needs a cleanup!
|
||||||
|
// Assigning state, while having callback removed
|
||||||
|
// TCocoaButton.setState is causing OnChange event, if callback is not nil
|
||||||
|
cb := TCocoaButton(btn).callback;
|
||||||
|
TCocoaButton(btn).callback := nil;
|
||||||
|
btn.setState(buttonState[NewState]);
|
||||||
|
TCocoaButton(btn).callback := cb;
|
||||||
|
end
|
||||||
|
else
|
||||||
|
btn.setState(buttonState[NewState]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure ScrollViewSetScrollStyles(AScroll: TCocoaScrollView; AStyles: TScrollStyle);
|
procedure ScrollViewSetScrollStyles(AScroll: TCocoaScrollView; AStyles: TScrollStyle);
|
||||||
@ -801,13 +816,6 @@ begin
|
|||||||
NSButton(btn).setAllowsMixedState(true);
|
NSButton(btn).setAllowsMixedState(true);
|
||||||
{$endif}
|
{$endif}
|
||||||
;
|
;
|
||||||
//todo: This place needs a cleanup!
|
|
||||||
// Assigning state, while having callback removed
|
|
||||||
// TCocoaButton.setState is causing OnChange event, if callback is not nil
|
|
||||||
cb := btn.callback;
|
|
||||||
btn.callback := nil;
|
|
||||||
ButtonSetState(btn, TCustomCheckBox(AWinControl).State);
|
|
||||||
btn.callback := cb;
|
|
||||||
Result := TLCLIntfHandle(btn);
|
Result := TLCLIntfHandle(btn);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -845,7 +853,7 @@ const
|
|||||||
buttonState: array [TcheckBoxState] of NSInteger = (NSOffState, NSOnState, NSMixedState);
|
buttonState: array [TcheckBoxState] of NSInteger = (NSOffState, NSOnState, NSMixedState);
|
||||||
begin
|
begin
|
||||||
if not ACustomCheckBox.HandleAllocated then Exit;
|
if not ACustomCheckBox.HandleAllocated then Exit;
|
||||||
ButtonSetState(NSButton(ACustomCheckBox.Handle), ACustomCheckBox.State);
|
ButtonSetState(NSButton(ACustomCheckBox.Handle), NewState);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSCustomCheckBox.GetPreferredSize(
|
class procedure TCocoaWSCustomCheckBox.GetPreferredSize(
|
||||||
@ -889,15 +897,9 @@ class function TCocoaWSRadioButton.CreateHandle(const AWinControl: TWinControl;
|
|||||||
const AParams: TCreateParams): TLCLIntfHandle;
|
const AParams: TCreateParams): TLCLIntfHandle;
|
||||||
var
|
var
|
||||||
btn: TCocoaButton;
|
btn: TCocoaButton;
|
||||||
cb: IButtonCallback;
|
|
||||||
begin
|
begin
|
||||||
btn := AllocButton(AWinControl, TLCLRadioButtonCallback, AParams, 0, NSRadioButton);
|
btn := AllocButton(AWinControl, TLCLRadioButtonCallback, AParams, 0, NSRadioButton);
|
||||||
Result := TLCLIntfHandle(btn);
|
Result := TLCLIntfHandle(btn);
|
||||||
//todo: this needs to be improved!
|
|
||||||
cb := btn.callback;
|
|
||||||
btn.callback := nil;
|
|
||||||
ButtonSetState(btn, TCustomCheckBox(AWinControl).State);
|
|
||||||
btn.callback := cb;
|
|
||||||
end;
|
end;
|
||||||
|
|
||||||
class procedure TCocoaWSRadioButton.SetState(
|
class procedure TCocoaWSRadioButton.SetState(
|
||||||
|
Loading…
Reference in New Issue
Block a user