Surprisingly, I can’t seem to find an answer for this. I have an audio plugin and I want to display a dialog with a custom component. I am using DialogWindow::LaunchOptions. I want to have the dialog box open centered on my plugin main editor. The componentToCentreAround field implies I can have the window centered around any component. I can’t seem to make it work setting that equal to my AudioProcessorEditor. Instead, the dialog is always centered on my computer monitor. I was thinking possibly that componentToCentreAround must be a Window class, or a TopLevelWindow, but experiments with that did not work either. Any ideas?
My apologies…I found the problem minutes after I posted. The problem is my last two lines.
DialogWindow::LaunchOptions options; OptionalScopedPointer<Component> ptr((Component *) &settings, false); options.content = ptr; Rectangle<int> area(0, 0, 350, 350); options.content->setSize(area.getWidth(), area.getHeight()); options.dialogTitle = "Settings"; options.componentToCentreAround = this; options.dialogBackgroundColour = findColour(ResizableWindow::backgroundColourId); options.escapeKeyTriggersCloseButton = true; options.useNativeTitleBar = true; options.resizable = false; auto dialogWindow = options.launchAsync(); if (dialogWindow != nullptr) dialogWindow->centreWithSize(area.getWidth(), area.getHeight());