If I point a button events “key released” and “mouse button released” to the same sub/function, is there a way to determine which event was activated?
I thought of raising an error, but would like to find a more graceful method of doing this:
If I point a button events “key released” and “mouse button released” to the same sub/function, is there a way to determine which event was activated?
I thought of raising an error, but would like to find a more graceful method of doing this:
I came up with the following solution/workaround, but if someone would be kind enough to suggest a more germane approach, I’d be very grateful.
dim x as string
x = oEvt.dbg_properties
x = mid(x, inStr(x, “”"")+1)
x = mid(x, 1, instr(x, “:”) -2)
This gives the full event name. In my case “com.sun.star.awt.KeyEvent” or “com.sun.star.awt.MouseEvent”
… then I create additional difficulties for myself.
UNO structure type in LO Basic can be found a little shorter.
Of course, I completely forgot about the split command. Nonetheless, I’m still glad that at least my general idea was somewhat in the right direction. Spasibo bolshoye!!
@sokol92 I just realized that you are not recommending those two events to be pointing to the same function?
Structures for mouse and keyboard events have different elements - don’t we pay a tax on the number of processing macros?
On the other hand, we can combine mouse (or keyboard) event handling for different sources (such as controls).
Very true indeed. Thank you.
By the way, if we are talking about a button, it is more convenient to work with a high-level event ActionEvent (it is called Execute Action
in the list of control’s events).
Then we will handle both the mouse click and the corresponding keyboard equivalent in one place. The circle is closed!
I need to finish what I’m doing the way I know how to, test it, and put it into production. Once that’s done, I will need to get back to the drawing board and keep improving it, and at the same time learning new techniques. This is definitely something that I’ll need to revisit and implement. Thank you @sokol92