Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

about IID_ICONTROLVIEW and IID_IEVENTHANDLER of kRollOverIconPushButtonBoss in c++ plug-in

Explorer ,
Jul 24, 2025 Jul 24, 2025

I inherited from kRollOverIconPushButtonBoss because I wanted to customize the appearance of the button. So, I overrode the IID_ICONTROLVIEW interface and implemented the Draw() function like this:

class MyButtonView : public DVControlView 
{
public:
    MyButtonView(IPMUnknown* boss);
    virtual ~MyButtonView();
    virtual void Draw(IViewPort* viewPort, SysRgn updateRgn = nil);
};

Everything works fine — I successfully implemented a custom-drawn button appearance.

However, the button click event stopped working.
I had to explicitly re-implement IID_IEVENTHANDLER for the button to respond to clicks again.

So my question is: why is this the case?
If I re-implement IID_ICONTROLVIEW, do I also have to re-implement IID_IEVENTHANDLER for the button to function properly?

TOPICS
SDK
196
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 24, 2025 Jul 24, 2025

What part of it does not work?

If you watch the control from an observer, are notifications missing?

Or is it visual feedback - your code not considering whatever flag is used to differentiate the state?

Did you set a breakpoint in the Draw, is it reached? Does it consider 

IID_ITRISTATECONTROLDATA?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 24, 2025 Jul 24, 2025

In my dialog's observer, I already have this line:

AttachToWidget(kmy_button_WidgetID, ITriStateControlData::kDefaultIID, panelControlData);

And in the Update() function, I can receive the button's click event normally.

However, when I re-implement IID_ICONTROLVIEW, and in my MyButtonView class I only override the Draw() function, the Update() method no longer receives the button click event.

To make it work again, I have to explicitly implement IID_IEVENTHANDLER, like this:

bool16 MyButtonEventHandler::LButtonDn(IEvent* e)
{
    InterfacePtr<IControlView> iControlView(this, UseDefaultIID());
    if (iControlView)
    {
        iControlView->Hilite();
        iControlView->Invalidate();
    }

    InterfacePtr<ISubject> iSubject(this, UseDefaultIID());
    if (iSubject)
    {
        iSubject->Change(kTrueStateMessage, ITriStateControlData::kDefaultIID);
    }

    return true;
}

And in the .fr resource definition:

Class
{
    kSVGRollOverIconButtonBoss,
    kRollOverIconPushButtonBoss,
    {
        IID_ICONTROLVIEW,     kMyButtonViewImpl,
        IID_IEVENTHANDLER,    kMyButtonEventHandleImpl,
    }
}

 

Now, here's the strange part:

  • If I do not override either IID_ICONTROLVIEW or IID_IEVENTHANDLER and just inherit everything from kRollOverIconPushButtonBoss, then everything works fine — the button displays and responds to clicks as expected.

  • But if I only override IID_ICONTROLVIEW, then the button stops responding to clicks — I can no longer receive click events in the observer.

  • I have to re-implement IID_IEVENTHANDLER as shown above to make the button work again.

So my question is:

Is this behavior expected?
When I override IID_ICONTROLVIEW, am I also supposed to override other methods in addition to Draw()?
Or is there something else I'm missing that causes the default click behavior to stop working?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 25, 2025 Jul 25, 2025

Do you use the debug build?

Looking thru my sources I found an old overloaded kRollOverIconButtonBoss.

The IControlView was #if'ed out in version 9 (move from Carbon to Drover) because of an assert from DVIconSuiteButtonTristateControlData.

That ControlData was expecting a certain counterpart in its drover peer.

Near that I'm now using a kBaseWidgetBoss as base for an icon widget.

 

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Jul 25, 2025 Jul 25, 2025
LATEST

Thank you. I don't have a debug version of InDesign — I'm using the release version along with message boxes for debugging and development.
Although it's quite difficult, it's the only option I have right now.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Jul 24, 2025 Jul 24, 2025

On the other hand, widget functionality that was once implemented with OS controls is increasingly moved into "Drover" and the emulation keeping our old boss objects alive has plenty optimizations.

If you look deeper at the docs, they explicitly mention event handlers. Could be one of those cases, and your adding an event handler triggers a slower emulation mode.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines