@@ -28,11 +28,15 @@ TPyDelphiControl = class (TPyDelphiComponent)
2828 function SendToBack_Wrapper (args : PPyObject) : PPyObject; cdecl;
2929 function SetBounds_Wrapper (args : PPyObject) : PPyObject; cdecl;
3030 function Repaint_Wrapper (args : PPyObject) : PPyObject; cdecl;
31+ function CanFocus_Wrapper (args: PPyObject): PPyObject; cdecl;
32+ function SetFocus_Wrapper (args: PPyObject): PPyObject; cdecl;
33+ function ResetFocus_Wrapper (args: PPyObject): PPyObject; cdecl;
3134 // Property Getters
3235 function Get_Parent ( AContext : Pointer) : PPyObject; cdecl;
3336 function Get_Visible (AContext: Pointer): PPyObject; cdecl;
3437 function Get_ControlsCount ( AContext : Pointer) : PPyObject; cdecl;
3538 function Get_Controls (AContext: Pointer): PPyObject; cdecl;
39+ function Get_IsFocused ( AContext : Pointer) : PPyObject; cdecl;
3640 // Property Setters
3741 function Set_Parent ( AValue : PPyObject; AContext : Pointer) : integer; cdecl;
3842 function Set_Visible (AValue: PPyObject; AContext: Pointer): integer; cdecl;
@@ -91,6 +95,18 @@ function TPyDelphiControl.BringToFront_Wrapper(args: PPyObject): PPyObject;
9195 end ;
9296end ;
9397
98+ function TPyDelphiControl.CanFocus_Wrapper (args: PPyObject): PPyObject;
99+ begin
100+ // We adjust the transmitted self argument
101+ Adjust(@Self);
102+ with GetPythonEngine do begin
103+ if PyArg_ParseTuple( args, ' :CanFocus' ) <> 0 then begin
104+ Result := VariantAsPyObject(DelphiObject.CanFocus)
105+ end else
106+ Result := nil ;
107+ end ;
108+ end ;
109+
94110function TPyDelphiControl.LocalToAbsolute_Wrapper (
95111 args: PPyObject): PPyObject;
96112var
@@ -126,6 +142,12 @@ function TPyDelphiControl.Get_ControlsCount(AContext: Pointer): PPyObject;
126142 Result := GetPythonEngine.PyLong_FromLong(DelphiObject.ControlsCount);
127143end ;
128144
145+ function TPyDelphiControl.Get_IsFocused (AContext: Pointer): PPyObject;
146+ begin
147+ Adjust(@Self);
148+ Result := GetPythonEngine.VariantAsPyObject(DelphiObject.IsFocused);
149+ end ;
150+
129151function TPyDelphiControl.Get_Controls (AContext: Pointer): PPyObject;
130152begin
131153 Adjust(@Self);
@@ -157,6 +179,8 @@ class procedure TPyDelphiControl.RegisterGetSets(PythonType: TPythonType);
157179 ' Returns the count of contained controls' , nil );
158180 PythonType.AddGetSet(' Controls' , @TPyDelphiControl.Get_Controls, nil ,
159181 ' Returns an iterator over contained controls' , nil );
182+ PythonType.AddGetSet(' IsFocused' , @TPyDelphiControl.Get_IsFocused, nil ,
183+ ' Determines whether the control has input focus.' , nil );
160184end ;
161185
162186class procedure TPyDelphiControl.RegisterMethods (PythonType: TPythonType);
@@ -180,6 +204,15 @@ class procedure TPyDelphiControl.RegisterMethods(PythonType: TPythonType);
180204 PythonType.AddMethod(' AbsoluteToLocal' , @TPyDelphiControl.AbsoluteToLocal_Wrapper,
181205 ' TControl.AbsoluteToLocal()' #10 +
182206 ' Converts the screen coordinates of a specified point on the screen to client coordinates.' );
207+ PythonType.AddMethod(' CanFocus' , @TPyDelphiControl.CanFocus_Wrapper,
208+ ' TControl.CanFocus()' #10 +
209+ ' Indicates whether a control can receive focus. ' );
210+ PythonType.AddMethod(' SetFocus' , @TPyDelphiControl.SetFocus_Wrapper,
211+ ' TControl.SetFocus()' #10 +
212+ ' Gives the input focus to the control.' );
213+ PythonType.AddMethod(' ResetFocus' , @TPyDelphiControl.ResetFocus_Wrapper,
214+ ' TControl.ResetFocus()' #10 +
215+ ' Removes the focus from a control of from any children of the control.' );
183216end ;
184217
185218function TPyDelphiControl.Repaint_Wrapper (args: PPyObject): PPyObject;
@@ -195,6 +228,19 @@ function TPyDelphiControl.Repaint_Wrapper(args: PPyObject): PPyObject;
195228 end ;
196229end ;
197230
231+ function TPyDelphiControl.ResetFocus_Wrapper (args: PPyObject): PPyObject;
232+ begin
233+ // We adjust the transmitted self argument
234+ Adjust(@Self);
235+ with GetPythonEngine do begin
236+ if PyArg_ParseTuple( args, ' :ResetFocus' ) <> 0 then begin
237+ DelphiObject.ResetFocus();
238+ Result := ReturnNone;
239+ end else
240+ Result := nil ;
241+ end ;
242+ end ;
243+
198244function TPyDelphiControl.AbsoluteToLocal_Wrapper (
199245 args: PPyObject): PPyObject;
200246var
@@ -248,6 +294,19 @@ procedure TPyDelphiControl.SetDelphiObject(const Value: TControl);
248294 inherited DelphiObject := Value ;
249295end ;
250296
297+ function TPyDelphiControl.SetFocus_Wrapper (args: PPyObject): PPyObject;
298+ begin
299+ // We adjust the transmitted self argument
300+ Adjust(@Self);
301+ with GetPythonEngine do begin
302+ if PyArg_ParseTuple( args, ' :SetFocus' ) <> 0 then begin
303+ DelphiObject.SetFocus;
304+ Result := ReturnNone;
305+ end else
306+ Result := nil ;
307+ end ;
308+ end ;
309+
251310function TPyDelphiControl.Set_Parent (AValue: PPyObject;
252311 AContext: Pointer): integer;
253312var
0 commit comments