How to use ` juce::isForegroundOrEmbeddedProcess`

So I’ve duplicated juce::FileBrowserComponent because I need to modify some behaviour and it’s impossible to sub-class it as nearly all the stuff I need to modify is private.

So the only real problem is this line in the timerCallback:

void FileBrowserComponent::timerCallback()
{

    const auto isProcessActive = isForegroundOrEmbeddedProcess (this);

ERROR: Use of undeclared identifier ‘isForegroundOrEmbeddedProcess’

Tried replacing with:

    const auto isProcessActive = juce::isForegroundOrEmbeddedProcess (this);

Error: No member named ‘isForegroundOrEmbeddedProcess’ in namespace ‘juce’

It seems there is actually no way to call this from a class that is outside JUCE.

I replaced it with just this:

    const auto isProcessActive = Process::isForegroundProcess();

… but I’m wondering it there’s any way to use this?

That function is a bit hidden in juce_gui_basics.cpp (would have never guessed there are any implementations)

So you got it half way through already…

But if you tell what you want to customize, maybe there is a way without copying the class?

Thanks, daniel. I want to use the JUCE file browsers, but I wanted to make them act more like MacOS. There are many behaviors to be modified, but one (for example):

When you use the Open dialog, you have to double-click to descend into a directory. If you select a directory with the mouse, the OPEN button remains grayed out. You cannot use it to OPEN the directory. I don’t want to be able to “select” the directory, I just want to use the OPEN button to descend into it - which is how MacOS works.

This requires modification of many things in FileChooserDialogBox, which reference private member variables.

A second example: The filepath comboBox at the top lists recent paths visited at the bottom of the list. It puts the full path name in there. Nobody likes to look at things like this, only a programmer would:

/Users/stephen/Documents/MyFiles/Projects/NewProject/tempfiles

I’d like it just to show ‘tempfiles’ the way MacOS does. However, when you select the shortened path name, it still has to store the long path name somewhere to act upon the selection.

This requires an extensive modification of FileBrowserComponent::setRoot(), among others. Even if it could be overridden it references many private member variables.

Lastly, I’m using it as a component installed over/inside my MainComponent as a child that blocks everything underneath it with a semi-transparent layer, and avoiding the use of the ModalComponentManager or it being a separate window, to avoid all the problems associated with that in a plugin.

It seems at this point I have it all working quite well; just was not quite sure what effect that missing function call would have and whether there was any way to change my syntax to use it. It seems to be something for Windows/Linux.

So actually, I had to duplicate both FileChooserDialogBox and FileBrowserComponent to get these things to work.

Wow, sounds like a really nice browser.
I agree, it is almost a new browser from scratch, not much point trying to get the original abused to get there.

I think at that point I would just keep the API, so you can easily replace the original if you want.

1 Like