Greetings, Pau -
First, what version/release/build of PowerBuilder are you using?
Second, from what object/event/function are you invoking the GetFocus PowerScript function?
The function works fine for me. I created an unmapped user event in a sheet window named ue_GetFocus that takes no arguments and returns no value, and placed this code in it:
String ls_classname
GraphicObject lgo_test
lgo_test = GetFocus()
If IsValid(lgo_test) Then
ls_classname = lgo_test.ClassName()
MessageBox('GetFocus Test','The object named "'+ls_classname+'" has input focus.')
Else
MessageBox('GetFocus Test','The GraphicObject reference is not valid.')
End If
In a new "GetFocus Test" menu item in my MDI test app, I placed the following:
Window lw_sheet
lw_sheet = gnv_app.of_GetFrame().GetActiveSheet()
If IsValid(lw_sheet) Then
lw_sheet.Event Dynamic ue_GetFocus()
Else
MessageBox('GetFocus Test','There is no active sheet window.')
End If
When the sheet window is opened, I navigate to any control in the window via the tab key, then click on the "GetFocus Test" menu item, and the name of the control that has input focus is displayed. For example:
I'm using PB 2017 R2.
HTH. John
Your code is working for me, I don't know what I was doing wrong but It's ok.
Thanks greetings.