I’m a bit lost on this, how do I know what item was clicked, how to attach a listener to the FileTreeComponent (EX) I’m doing? I know how to do the “dirty” way, but since I plan on making the code public, I rather do the Right way. :oops:
Wk
I’m a bit lost on this, how do I know what item was clicked, how to attach a listener to the FileTreeComponent (EX) I’m doing? I know how to do the “dirty” way, but since I plan on making the code public, I rather do the Right way. :oops:
Wk
erm… call addListener? (I can’t think of a “dirty” way!)
Hehe, ok, I know that, but I couldn’t figure out HOW to do that. :oops: But don’t worry, I will read more, until I do.
Ok, here’s the Dirty way. I just add a void pointer variable to the class, something like Owner or edEditor. Then, during startup, I just do
fileTree = new FileTreeComponentEx(…, this)
Now, inside FileTreeComponentEx I just do ((Editor*)owner)->whateverIwantFromTheEditor…
EG: ((Editor*)owner)->LoadNewFileFromTreeview(File file);
Its simple, but its “dirty”. :mrgreen:
Wk
Oh, I see - you mean you’re adding your own type of listener, not a juce listener class? Well, just copy the way all the juce classes do their listeners.
Ahhhh, yeah, I will check that, makes sense…
Thanks again Jules.
Wk
Ok, I understand now. Here’s some quick examples for N00bs like me, that have a hard time understand the simple things. :oops:
For example, I created my own component that I want to send a message that something was changed to the Plugin / Filter / Owner.
So, in my new component class, I add “public ChangeBroadcaster” to the construction. EX:
class FileTreeMain : public Component,
public ButtonListener,
public ChangeBroadcaster
{
Now, when I want to inform that something was changed, I call:
Now, I also use a public variable that holds what was changed, in this case, the name of the file that was selected from the list. (File newFile)
Now, in my Plugin Editor (GUI), I add public ChangeListener to its construction class:
class EditorComponent : public AudioProcessorEditor,
public ChangeListener
{
public:
void changeListenerCallback (void* source);
And in the changeListenerCallback call, I can check if source == the object I created for the file selection class above. EX:
void EditorComponent::changeListenerCallback (void* source)
{
if (source == (void*)fileTreeMain)
{
// Here I get the filename - fileTreeMain->loadFile.getFullPathName());
}
}
I hope this is handy for those learning things now. 8)
Wk