# Plugin window behaviour

**URL:** <https://forum.juce.com/t/plugin-window-behaviour/5389>\
**Category:** Audio Plugins\
**Created:** [June 17, 2010, 2:54pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389 "2010-06-17T14:54:36Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [June 17, 2010, 2:54pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/1 "2010-06-17T14:54:36Z")

</div>

I get weird stuff in my plugins

- i use a MenuBarComponent and a global ApplicationManager, all menus are greyed-out most of the time, i need to click many times in weird places (can’t really tell witch place makes it work)
- when i click on a menu option it opens and closed the menu instantly, can’t select any option, i need to click somewhere where there is no option and then click on the menu again (some focus issues i guess)
- on the mac when i open a ModalDialog it’s always behhind the plugin window and i can’t bring it to front no matter what

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 17, 2010, 3:00pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/2 "2010-06-17T15:00:47Z")

</div>

The menu will be greyed out if your window isn’t focused - maybe you just need to make it focusable?

If the host has made the plugin window always-on-top, then you’ll need to setAlwaysOnTop in your dialogs too…

And try the latest git code, I did some menu changes this week, that might make a difference.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [June 17, 2010, 3:11pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/3 "2010-06-17T15:11:47Z")

</div>

allrighty will pull the git code at night when my mind starts working and will rebuild everything from scratch.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [June 17, 2010, 4:50pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/4 "2010-06-17T16:50:47Z")

</div>

Well i have a crash with the new code, in standalone mode the deleteFilter() method crashes on exit

```auto
setContentComponent (0, true);
```

ResizableWindow method crashes when doing this assign:

```auto
contentComponent = newContentComponent;
```

it’s the ScopedPointer crash here:

```auto
ScopedPointer& operator= (ObjectType* const newObjectToTakePossessionOf)
	{
		if (object != newObjectToTakePossessionOf)
		{
			ObjectType* const oldObject = object;
			object = newObjectToTakePossessionOf;
			delete oldObject <---- crash;
		}

		return *this;
	}
```

it worked for a very very long time

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 17, 2010, 8:41pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/5 "2010-06-17T20:41:45Z")

</div>

I can’t see any obvious bugs. It sounds like you’re deleting the editor component yourself, so that the resizablewindow is left with a dangling pointer…? Could be that in the older code, the resizablewindow checked the pointer before deleting it, and you managed to get away with it, whereas now it’s less forgiving.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [June 17, 2010, 11:21pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/6 "2010-06-17T23:21:15Z")

</div>

it’s weird, it’s not any of my plugin code, actually the thing that fails is the deletion of a TableListBox that i added to one of my components, if i comment out the deleteAndZero (myTableListBox) that Jucer created, there is no crash but there is a memory leak for that TableListBox component, don’t really know what to do, deleting it crashes not deleting it leaks memory.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [June 18, 2010, 8:16am UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/7 "2010-06-18T08:16:01Z")

</div>

That sounds like a red herring to me - more likely that if you don’t delete the listbox then you happen to not see the crash just because of the way the heap is laid out. You need to put a breakpoint in your content component’s destructor and see where it’s getting deleted. It should be deleted by the scopedpointer, but my guess is that something else is getting there first.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 5, 2010, 12:21pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/8 "2010-07-05T12:21:30Z")

</div>

as always i’m using the latest tip…

the menubar focus/all options greyed out/flicker issue is still there, i used the plugin host and it’s there, the menu bar is very hard to operate, clicking on an option does not always show the menu, once used the menu get;s greyed out and it’s near to impossible to turn those options back on no matter what i click on the plugin window to gain focus, it’s all very weird.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 19, 2010, 10:58pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/9 "2010-07-19T22:58:04Z")

</div>

I just wanted to follow up on this. I click on the window, open the menu and the options are active, but once i move to some other menu (left/right) the menu greys everything out. So the focus is momentary only when i open the menu and then lost, even though the options are normal (not greyed out) on the first enter i can’t trigger any of them.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2010, 7:27pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/10 "2010-07-21T19:27:30Z")

</div>

Perhaps you just need to use setWantsKeyboardFocus (true) on your plugin component? It just sounds like the main comp doesn’t want focus, and you’re having to click on child comps that do want focus in order for it to work…

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 21, 2010, 8:40pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/11 "2010-07-21T20:40:10Z")

</div>

it does not work for VST  
standalone seems to work with or without that  
the same thing happens to the old JUCER, the menu acts extremly weird, not loosing focus when editing components (the menu stays selected), and other stuff, so this is not my code related.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 21, 2010, 9:47pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/12 "2010-07-21T21:47:43Z")

</div>

The menus seem fine to me… What would I have to do to get the jucer or juce demo to do this?

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 21, 2010, 10:55pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/13 "2010-07-21T22:55:07Z")

</div>

[http://www.screentoaster.com/watch/stUElWQENJRFtYSVpZWVxfUV9X/jucer\_not\_working](http://www.screentoaster.com/watch/stUElWQENJRFtYSVpZWVxfUV9X/jucer_not_working)  
[http://www.screentoaster.com/watch/stUElWQENJRFtYSVpZWVJcU15Q/plugin\_wrapper\_menu\_bar](http://www.screentoaster.com/watch/stUElWQENJRFtYSVpZWVJcU15Q/plugin_wrapper_menu_bar)

here are two videos that demonstrate this, theese apps are pure builds of your code nothing modified, i use Win7 x32 and VCExpress.

also i have JucePlugin\_EditorRequiresKeyboardFocus set in my pluginchahracteristics file.

i create my appManager in the plugin constructor (the fitler no the UI class)

```auto
applicationCommandManager = new ApplicationCommandManager();
```

then in my UI editor constructor i do:

```auto
setWantsKeyboardFocus (true);
commandManager->registerAllCommandsForTarget (this);
setApplicationCommandManagerToWatch (commandManager);
```

my UI editor class is a subclass of: MenuBarModel, ApplicationCommandTarget, ChangeListener, FileDragAndDropTarget, AudioProcessorEditor  
and that’s it

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 22, 2010, 12:45pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/14 "2010-07-22T12:45:29Z")

</div>

also i mentioned this some time ago, but when setting a default value for a constructor parameter it gets declared in both the class definition and implementation witch causes a compiler error (re-definition).

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [July 27, 2010, 9:43am UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/15 "2010-07-27T09:43:49Z")

</div>

any ideas anyone ? maybe i’m doing something so obviously wrong i just can’t see it (it’s often the case).

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [July 27, 2010, 10:35am UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/16 "2010-07-27T10:35:55Z")

</div>

It all looks focus-related, I expect that the plugin window just isn’t getting focused until you click inside it, but TBH I’m not surprised that there could be focus issues when trying to use a menu bar in a plugin, it’s quite complicated when you’ve got host/plugin windows all mixed together like that. I’ll try to take a look as soon as I can.

---

<div class="post-metadata">

**Author:** ![atom](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/atom/32/113_2.png) [@atom](https://forum.juce.com/u/atom)\
**Post date:** [August 6, 2010, 1:41pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/17 "2010-08-06T13:41:29Z")

</div>

I got some feedback from users, this affects also MAC builds, in both VST and AU versions, i got reports from people using LOGIC and i checked that in Live and it has the same problem.

---

<div class="post-metadata">

**Author:** ![steffen](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@steffen](https://forum.juce.com/u/steffen)\
**Post date:** [November 12, 2010, 2:16pm UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/18 "2010-11-12T14:16:45Z")

</div>

I’m in the same boat, having a PluginEditor that extends ApplicationCommandTarget and though I tried everything mentioned in this thread, all menu-items for commands implemented by the PluginEditor are disabled until I click anywhere in the plugin.

This doesn’t seem to be host-specific as it is the exact same behaviour for at least ableton live (win/mac), logic 8&9 (mac) and dp6 (mac).

things I tried include:

- explicitly calling ApplicationCommandManager::commandStatusChanged after my PluginEditor is created
- explcitly calling MenuBarModel::menuItemsChanged() after my PluginEditor is created

did anyone find a solution to this issue yet?

---

<div class="post-metadata">

**Author:** ![steffen](https://avatars.discourse-cdn.com/v4/letter/s/df788c/32.png) [@steffen](https://forum.juce.com/u/steffen)\
**Post date:** [November 15, 2010, 10:40am UTC](https://forum.juce.com/t/plugin-window-behaviour/5389/19 "2010-11-15T10:40:44Z")

</div>

I was able to work around this issue by explicitly grabbing the keyboard focus from the plugin-editor. The tricky bit was that it did not work when called from inside the editor’s constructor, so I used a timer to delay the call:

```auto
MyPluginEditor::MyPluginEditor
{
    [...]
    startTimer(20);
}

void MyPluginEditor::timerCallback()
{
    grabKeyboardFocus();
    stopTimer();
}
```
