Ask Your Question

Is there a function in LO Basic that returns the name of the form control that has focus? [closed]

asked 2016-03-26 01:36:29 +0100

docbda gravatar image

updated 2016-03-26 03:22:12 +0100

I need to assign the name of the form control that has focus (in this instance one of several text boxes) to a variable in a LO basic macro. Is anyohe aware of a function that accomplishes this? I've been looking for a few hours with no luck.

More specifically, the macro is being designed to be triggered by an image button elsewhere on the form upon a mouse click. I'm attempting to design the macro so it will insert a text string into the textbox that has focus at the time the image button is clicked. The target textbox will have focus due to the user having just added text via the keyboard with the cursor still residing in the textbox at the time the image button is clicked. If there is a function that will return the name of the form control that has focus at the time the function is called (something like "getByFocus()") it would make my life a lot easier. So far, my searching has not turned up such an animal. The closest thing I've found thus far is "getCurrentController()"

Thanks in advance. docbda

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Ratslinger
close date 2016-03-26 18:45:33.985154

1 Answer

Sort by » oldest newest most voted

answered 2016-03-26 03:35:39 +0100

Ratslinger gravatar image

Once the image has been clicked, the textbox focus is lost. The image button now has focus. You may want to consider macros tied to the textbox event 'When losing focus'. The macro could set a unique id to be read by the macro called by the image click. That id could then tell you where to send your result.

edit flag offensive delete link more


lol...that was a bonehead move on my part. I didn't think about the fact that the focus switched to the image button upon clicking it. I think I've been at this too long. Thanks for the tip, ratslinger. Time to do something else... cheers, docbda

docbda gravatar imagedocbda ( 2016-03-26 03:42:34 +0100 )edit

I did find a way around the push button taking focus from the textbox. Under the form control properties for a push button, under the "general" tab there is an option "take focus on click". If this option is set to "no", then the textbox that was last selected by the user should retain focus. It would still be good to know if a function in LO basic does exist that returns the identity of the text box, or other control, that has focus so it can be assigned a variable and manipulated as desired

docbda gravatar imagedocbda ( 2016-03-28 18:23:27 +0100 )edit

Question Tools

1 follower


Asked: 2016-03-26 01:36:29 +0100

Seen: 173 times

Last updated: Mar 26 '16