How to find the name or number of the control with focus in Base Macro Basic

How to find the name or number of the control with focus in Base Macro Basic
Bing gave me this
oForm = ThisComponent.Drawpage.Forms.getByName(“YourFormName”)
oController = ThisComponent.getCurrentController()
oControl = oController.getControl(oForm.ActiveControl)
Then this
oForm = ThisComponent.Drawpage.Forms.getByName(“YourFormName”)
oController = ThisComponent.getCurrentController()
oControl = oController.getControl(oController.ActiveControl)
Then this
oForm = ThisComponent.Drawpage.Forms.getByName(“YourFormName”)
oController = ThisComponent.getCurrentController()
oControl = oController.getControl(oController.FocusedControl.Model.Name)
They all failed on the last line. would getCurrentController()” be any better,
Please help.

Install XRay.
XrayTool60_de.odt (819.8 KB)
This is only the German description, but GUI will run in English.
On page 5 is a button “Xray installieren”.
Press the button and xray will be copied into your Basic user folder.
Open editing of macros.
Click on the folder for xray. So xray will be a known command.+
Then do this:

oController = ThisComponent.getCurrentController()
xray oController

This will show all possibilities you have for oController.
But: I don’t understand why you want to get the message which field has the focus. Never needed this.

Thanks you seem to be helping me a lot. Xray does what I have been doing in watch except a lot clearer. Still no control numbers or names. Unless I’ve missed something.
The reason I want the focused control is the form has over 80 small text boxes and I don’t want a sub for each when their focus status changes. Just 1 sub find it’s name and continue. So any further help will be appreciated.

You just need a one Sub for everyone. Set all the controls in the event: When receiving focus

Dim txt_name As String


Sub focus_gain(event)	
	txt_name = event.Source.Model.Name	
End Sub
2 Likes

Thankyou, just what the doctor ordered. Without pushing my luck… Any chance of finding out more about the options for Event.
event.Source.Model.Name

Sub proto_typing(event)	
	mri event
End Sub

install mri.oxt from here

btw. xray mentioned by @RobertG should work the same way

1 Like