Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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?
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Find more inspiration, events, and resources on the new Adobe Community
Explore Now