Skip to content

Commit 250a99d

Browse files
committed
Wrapper for TMouseButton
1 parent c93e0b9 commit 250a99d

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

Source/WrapDelphiTypes.pas

+18-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ interface
99
SysUtils,
1010
PythonEngine,
1111
Types,
12-
WrapDelphi;
12+
WrapDelphi
13+
{$IFDEF DELPHI10_OR_HIGHER}
14+
, System.UITypes
15+
{$ENDIF DELPHI10_OR_HIGHER}
16+
;
1317

1418
type
1519
TPyDelphiPoint = class(TPyObject)
@@ -95,14 +99,14 @@ TPyDelphiSize = class(TPyObject)
9599
function CheckRectAttribute(AAttribute : PPyObject; const AAttributeName : string; out AValue : TRect) : Boolean;
96100
function CheckSizeAttribute(AAttribute : PPyObject; const AAttributeName : string; out AValue : TSize) : Boolean;
97101

102+
{$IFDEF DELPHI10_OR_HIGHER}
103+
function MouseButtonToPython(const AMouseButton: TMouseButton): PPyObject;
104+
{$ENDIF DELPHI10_OR_HIGHER}
105+
98106
implementation
99107

100108
uses
101-
Math
102-
{$IFDEF DELPHI10_OR_HIGHER}
103-
, System.UITypes
104-
{$ENDIF DELPHI10_OR_HIGHER}
105-
;
109+
Math, Rtti;
106110

107111
{ Register the wrappers, the globals and the constants }
108112
type
@@ -158,6 +162,14 @@ procedure TTypesRegistration.RegisterWrappers(APyDelphiWrapper: TPyDelphiWrapper
158162
APyDelphiWrapper.RegisterHelperType(TPyDelphiSize);
159163
end;
160164

165+
{$IFDEF DELPHI10_OR_HIGHER}
166+
function MouseButtonToPython(const AMouseButton: TMouseButton): PPyObject;
167+
begin
168+
Result := GetPythonEngine.PyUnicodeFromString(
169+
TRttiEnumerationType.GetName<TMouseButton>(AMouseButton));
170+
end;
171+
{$ENDIF DELPHI10_OR_HIGHER}
172+
161173
{ Helper functions }
162174

163175
function WrapPoint(APyDelphiWrapper : TPyDelphiWrapper; const APoint : TPoint) : PPyObject;

0 commit comments

Comments
 (0)