Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

How to properly code a broadcaster and listener in LO Basic

I have read Pitonyak's section on listeners in OOo Macros Explained, and it left me bewildered and confused (but bless his heart for taking the time to write such a comprehensive document on OOo Basic). Unfortunately, I'm quite new at coding in OOo Basic (and coding in general) and I'm trying to learn on the fly (by doing). Therefore, much of his explanation went zinging over my head.

That said, here's what I'm trying to accomplish:

I'm writing a macro contained within in a Base form. In this macro, I have several image buttons that when clicked pass a text string to a textbox via a short sub routine that is triggered when the mouse button is pressed on the image button. Each of these image buttons have their own unique text string. At times, I will need to concatinate two of these text strings together (originating from different buttons).

The problem is that I don't know in what order the buttons will be pushed, so I need the macro to detect when a second (or third, fourth, fifth, etc) is pushed and add the string associated with that button to the growing text string. Therefore, I need the macro to "listen" for one of the image buttons to be pushed (I'm assuming the image button would be the broadcaster), and when detected by the listener, pass the detected button's associated text string to the subroutine that is building the concatinated text string.

When I read Pitonyak's statement, "Knowing which broadcaster to use is not always an easy task. It requires understanding how OOo is designed; this comes with experience." I knew i was in trouble.

If someone would be kind enough to show me some example code that is a possible solution for the above, or point me toward a tutorial regarding this topic that is slanted more toward the beginner, I would be most appreciative.

Cheers.

docbda