Carbon: fix key events after toolbutton clicked inside toolbar. issue #19275

git-svn-id: trunk@34266 -
This commit is contained in:
zeljko 2011-12-19 08:06:59 +00:00
parent 808daec901
commit 38ffe4cb95
4 changed files with 40 additions and 2 deletions

View File

@ -45,10 +45,13 @@ type
TCarbonControlEvent = (cceValueChanged, cceIndicatorMoved, cceDoAction,
cceDraw, cceHit);
TCarbonControlEvents = set of TCarbonControlEvent;
TCarbonWidgetFlag = (cwfNone, cwdTToolBar);
{ TCarbonControl }
TCarbonControl = class(TCarbonWidget)
private
FCarbonWidgetFlag: TCarbonWidgetFlag;
protected
procedure RegisterEvents; override;
procedure CreateWidget(const AParams: TCreateParams); override;
@ -108,6 +111,8 @@ type
procedure SetMaximum(AValue: Integer);
procedure SetViewSize(AValue: Integer);
public
// needed to avoid "Class is" or "ClassType"
property CarbonWidgetFlag: TCarbonWidgetFlag read FCarbonWidgetFlag write FCarbonWidgetFlag;
{ Frame:
= widget in controls without special frame control
- frame area control of control
@ -153,6 +158,13 @@ type
property TextFractional: Boolean read FTextFractional write FTextFractional;
end;
{ TCarbonToolBar }
TCarbonToolBar = class(TCarbonCustomControl)
protected
procedure CreateWidget(const AParams: TCreateParams); override;
end;
{ TCarbonScrollingWinControl }
@ -719,8 +731,14 @@ end;
procedure TCarbonCustomControl.CreateWidget(const AParams: TCreateParams);
var
TmpSpec: EventTypeSpec;
AStyle: TControlStyle;
begin
Widget := CreateCustomHIView(ParamsToHIRect(AParams), LCLObject.ControlStyle);
AStyle := LCLObject.ControlStyle;
if CarbonWidgetFlag = cwdTToolBar then
AStyle := AStyle + [csNoFocus];
Widget := CreateCustomHIView(ParamsToHIRect(AParams), AStyle);
if Widget = nil then RaiseCreateWidgetError(LCLObject);
// The event must be installed before embedding ScrollView. related to #19425

View File

@ -125,6 +125,14 @@ begin
Result := CallNextEventHandler(ANextHandler, AEvent);
end;
{ TCarbonToolBar }
procedure TCarbonToolBar.CreateWidget(const AParams: TCreateParams);
begin
CarbonWidgetFlag := cwdTToolBar;
inherited CreateWidget(AParams);
end;
{ TCarbonControl }
{------------------------------------------------------------------------------
@ -308,6 +316,7 @@ end;
------------------------------------------------------------------------------}
procedure TCarbonControl.CreateWidget(const AParams: TCreateParams);
begin
CarbonWidgetFlag := cwfNone;
AddControlPart(Widget);
if Content <> ControlRef(Widget) then AddControlPart(Content);
end;

View File

@ -194,6 +194,7 @@ type
TCarbonWSToolBar = class(TWSToolBar)
published
class function CreateHandle(const AWinControl: TWinControl; const AParams: TCreateParams): TLCLIntfHandle; override;
end;
{ TCarbonWSTrackBar }
@ -224,6 +225,15 @@ implementation
uses
CarbonProc, CarbonTabs, CarbonDbgConsts;
{ TCarbonWSToolBar }
class function TCarbonWSToolBar.CreateHandle(const AWinControl: TWinControl;
const AParams: TCreateParams): TLCLIntfHandle;
begin
Result := TLCLIntfHandle(TCarbonToolBar.Create(AWinControl, AParams));
// TCarbonCustomControl(Result).
end;
{ TCarbonWSStatusBar }
{------------------------------------------------------------------------------

View File

@ -178,7 +178,8 @@ end;
function RegisterToolBar: Boolean; alias : 'WSRegisterToolBar';
begin
Result := False;
RegisterWSComponent(TToolbar, TCarbonWSToolBar);
Result := True;
end;
function RegisterCustomTrackBar: Boolean; alias : 'WSRegisterCustomTrackBar';