PDA

View Full Version : Get mouse events in MAC



vinayaka
25th January 2012, 10:02
We got the mouse events on the title bar using the following code in windows


bool RightSideBar::winEvent(MSG *msg, long *result)
{
if (msg->message == WM_NCLBUTTONUP)
{
//here can catch the leftmousedown event on titlebar
qDebug()<<"Title Bar Button Down";
}
return false;
}


But what should we do to get mouse events on title bar in MAC.
Any help?

vinayaka
27th January 2012, 04:50
bool RightSideBar::winEvent(MSG *msg, long *result)
{
bool retval = true;

switch (msg->message)
{

case WM_NCLBUTTONDOWN:
qDebug()<<"Using Windows API Button Down";
break;

case WM_NCLBUTTONUP:
qDebug()<<"Using Windows API Button UP";

break;
default:
retval = false;
}

return retval;
}



But here resize and widget move options are not working in our application.We also need the same event(winEvent) in MAC OS .Can anyone help us in this?

ChrisW67
27th January 2012, 06:05
QWidget::macEvent() seems fairly obvious (or QApplication::macEventFilter() for earlier Qt versions). Once you abandon the platform independence of Qt you are much less likely to get responses in here.

Your winEvent code returns true for these two events which will stop any further processing by Qt. Perhaps that is what is breaking the "resize and widget move options" you complain about.

vinayaka
31st January 2012, 06:06
we need to get the mouse up event on Application's Title bar in Windows and MAC OS.In window we got the solution,but in MAC we don't know how to get mouse up event on Title bar.


//Function for getting Mouse Event on TitleBar in Windows.

#ifdef Q_OS_WIN
bool RightSideBar::winEvent(MSG *msg, long *result)//This function working fine in our application
{

switch (msg->message)
{

case 562:
{
qDebug()<<"Using Windows API Mouse Button UP"<<msg->message;
return false;
break;
}


}

return false;
}
#endif
//End Function for getting Mouse Event on TitleBar in Windows.


//Function for getting Mouse Event on TitleBar in MAC.
#ifdef Q_OS_MAC
bool RightSideBar::macEvent(EventHandlerCallRef caller, EventRef event)
{
qDebug()<<"Inside MAC event.....";//we dont know how to get mouse event here
return false;
}
#endif


please help us..

ChrisW67
31st January 2012, 08:56
I Googled the docs for you: Cocoa Event-Handling Guide: Handling Mouse Events (http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/EventOverview/HandlingMouseEvents/HandlingMouseEvents.html#//apple_ref/doc/uid/10000060i-CH6-SW1). This is nothing to do with Qt.

The process probably goes something like this:

Use EventRef to get NSEvent *
Use NSEvent to check event type and get relevant mouse information

How you do that from C++ I don't know.