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

Unable to perform operation on mouse wheel event on panel window

Engaged ,
Oct 14, 2016 Oct 14, 2016

Copy link to clipboard

Copied

Hi All!

I am working on a plugin for AI CC 2015.3 that embeds Qt UI inside it.

I am following the EmptyPanel sample from the SDK samplecode. Here, the panel window is created using AIPanelPlatformWindow, and the controls like buttons etc. are added using native code.

I have embedded a Qt component inside the panel.

The issue I am facing is not entirely Qt specific nor entirely AI specific, so I am uncertain where to ask. Starting here.

The Qt component I have integrated is Qt3DWindow for 3d viewing.

I am using the window to load a 3d model.

Now, I have some mouse events to help the user move the model. The click and drag events work fine. I am able to move and rotate the model.

The problem is with the mouse wheel movement which I use for zooming.

All focus is on the AI parent application, if there is a document open, then the mouse wheel just scrolls the document. No affect on the model.

If I try the same thing on an independent Qt application, it works fine. So, I know the code isn't broken.

How can I fix this? Any ideas?

TOPICS
SDK

Views

830

Translate

Translate

Report

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
Adobe
Community Expert ,
Oct 14, 2016 Oct 14, 2016

Copy link to clipboard

Copied

So your question is about the SDK?

Votes

Translate

Translate

Report

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
Engaged ,
Oct 14, 2016 Oct 14, 2016

Copy link to clipboard

Copied

Yes. Any way I can get the scroll focus on my panel, rather than on the document?

Votes

Translate

Translate

Report

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
Community Expert ,
Oct 14, 2016 Oct 14, 2016

Copy link to clipboard

Copied

I have asked a moderator to move your question to the SDK forum

Votes

Translate

Translate

Report

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
Engaged ,
Oct 14, 2016 Oct 14, 2016

Copy link to clipboard

Copied

Thank you!

Votes

Translate

Translate

Report

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
Guide ,
Oct 24, 2016 Oct 24, 2016

Copy link to clipboard

Copied

Just took a look at how we handle it and you have to go OS-level to hook into that event to make it work with panels in Qt.

On WIndows, we setup a windows hook (SetWindowsHookEx) and then handle is thusly:

HWND GetCurrentDocumentWindow(); // you need to implement this, it's a bit of a pain

// the document window is the window of type OWLDocument (use Spy++) to find.

// We typically poll all the OWLDocument windows whenever we get a 'document opened' notifier from AI

// and the assumption is the first one we see that we didn't already know about is the OWLDocument associated

// with the new document (AIDocumentHandle); internally we store that association using a std::map<AIDocumentHandle, HWND>;

// this function just looks that up using AIDocument::GetDocument() as the key

bool IsPanelWindow(); // we keep track of all our panels and this basically just indicates if it's one of ours or not

bool IsChildOfPanelWindow(); // uses IsChild() to iterate over the children of all registered panel windows

HWND GetRootParent(HWND child)

{

     HWND current = GetParent(child);

     HWND result = 0;

     while (current != 0) {

          result = current;

          current = GetParent(current);

     }

     return result;

}

void SetFocusToIllustrator()

{

     // you need to push the application context here

     HWND docid = CDocumentList::GetCurrentDocumentWindow();

    HWND parentId = GetRootParent(docid);

     SetFocus(parentId);

}

LRESULT CALLBACK MouseProc(int nCode, WPARAM wParam, LPARAM lParam)

{

     if (nCode == HC_ACTION && wParam == WM_MOUSEWHEEL && !QApplication::activeModalWidget()) {

          MOUSEHOOKSTRUCTEX* info = (MOUSEHOOKSTRUCTEX*)lParam;

          POINT location = info->pt;

          QWidget* w = QApplication::topLevelAt(location.x, location.y);

          if (w) {

               QPoint qp(location.x, location.y);

               QWidget* child = w->childAt(w->mapFromGlobal(qp));

               if (child) {

                    short delta = (short)(HIWORD(info->mouseData)); // high order is delta

                    QWheelEvent* w = new QWheelEvent(child->mapFromGlobal(qp), qp, delta, 0, 0);

                    QApplication::postEvent(child, w);

                    return 1; // eat the event

               }

          } else {

               const HWND activeWindow = GetActiveWindow();

               // if the focus window is not illustrator then check if the focus window is one of our panel windows

               if (activeWindow != GetRootParent(GetCurrentDocumentWindow())) {

                    // if the mouse isn't over a qt window, but one of our windows has focus, then set focus back to illustrator

                    if (IsPanelWindow(focusWindowm) || IsChildOfPanelWindow(focusWindowm)) {

                         SetFocusToIllustrator();

                                        }

               }

          }

     }

     // g_windowMouseHook is what you get back when you register the mouse hook

     LRESULT result = CallNextHookEx(g_windowMouseHook, nCode, wParam, lParam);

     return result;

}

Votes

Translate

Translate

Report

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
Guide ,
Oct 24, 2016 Oct 24, 2016

Copy link to clipboard

Copied

Not sure what Mac needs; maybe less? I just know the Windows end of things. Hope it helps!

Votes

Translate

Translate

Report

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
Engaged ,
Nov 01, 2016 Nov 01, 2016

Copy link to clipboard

Copied

LATEST

Thanks a tonne!

It is indeed a direction I can move into..

One thing I encountered was that one of my colleagues has no such issues at his end.

The zooming works at the mouse wheel event..

Got me wondering if there is some setting inside AI or something else which can influence this.

Votes

Translate

Translate

Report

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