本文整理汇总了C++中WindowApplication::OnMouseClick方法的典型用法代码示例。如果您正苦于以下问题:C++ WindowApplication::OnMouseClick方法的具体用法?C++ WindowApplication::OnMouseClick怎么用?C++ WindowApplication::OnMouseClick使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WindowApplication
的用法示例。
在下文中一共展示了WindowApplication::OnMouseClick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ProcessMouseUp
//----------------------------------------------------------------------------
static pascal OSStatus ProcessMouseUp (EventHandlerCallRef, EventRef evt,
void*)
{
Point mouseLoc;
GetEventParameter(evt, kEventParamMouseLocation, typeQDPoint, 0,
sizeof(mouseLoc), 0, &mouseLoc);
EventMouseButton mouseButton;
GetEventParameter(evt, kEventParamMouseButton, typeMouseButton, 0,
sizeof(mouseButton), 0, &mouseButton);
UInt32 modifiers;
GetEventParameter(evt, kEventParamKeyModifiers, typeUInt32, 0,
sizeof(modifiers), 0, &modifiers);
WindowApplication* theApp =
(WindowApplication*)Application::TheApplication;
CGrafPtr currPort;
GetPort(&currPort);
SetPortWindowPort((WindowRef)(theApp->GetWindowID()));
GlobalToLocal(&mouseLoc);
SetPort(currPort);
theApp->OnMouseClick(mouseButton, WindowApplication::MOUSE_UP,
mouseLoc.h, mouseLoc.v, modifiers);
// Allow standard handler to run.
return eventNotHandledErr;
}
示例2: MouseClickCallback
//----------------------------------------------------------------------------
static void MouseClickCallback (int button, int state, int x, int y)
{
WindowApplication* theApp =
(WindowApplication*)Application::TheApplication;
if (theApp)
{
int modifiers = glutGetModifiers();
gsGLUTModifiers = *(unsigned int*)&modifiers;
if (state == WindowApplication::MOUSE_DOWN)
{
gsButton = button;
}
else
{
gsButton = -1;
}
theApp->OnMouseClick(button, state, x, y, gsGLUTModifiers);
}
}
示例3: Main
//.........这里部分代码省略.........
GlxRendererData* data = (GlxRendererData*)mRenderer->mData;
if (!data->FinishConstruction(window, mRenderer))
{
return -5;
}
if (theApp->OnInitialize())
{
// The default OnPreidle() clears the buffers. Allow the application
// to fill them before the window is shown and before the event loop
// starts.
theApp->OnPreidle();
// Display the window.
XMapWindow(display, window);
// Start the message pump.
bool applicationRunning = true;
while (applicationRunning)
{
if (!XPending(display))
{
theApp->OnIdle();
continue;
}
XEvent evt;
XNextEvent(display, &evt);
int index;
bool state;
if (evt.type == ButtonPress || evt.type == ButtonRelease)
{
theApp->OnMouseClick(evt.xbutton.button, evt.xbutton.type,
evt.xbutton.x, evt.xbutton.y, evt.xbutton.state);
if (evt.type == ButtonPress)
{
index = GLXAPP_BUTTONDOWN + evt.xbutton.button;
state = true;
SetExtraData(index, sizeof(bool), &state);
}
else
{
index = GLXAPP_BUTTONDOWN + evt.xbutton.button;
state = false;
SetExtraData(index, sizeof(bool), &state);
}
continue;
}
if (evt.type == MotionNotify)
{
int button = 0;
index = GLXAPP_BUTTONDOWN + 1;
GetExtraData(index, sizeof(bool), &state);
if (state)
{
button = MOUSE_LEFT_BUTTON;
}
else
{
index = GLXAPP_BUTTONDOWN + 2;
GetExtraData(index, sizeof(bool), &state);
示例4: MsWindowEventHandler
//.........这里部分代码省略.........
{
theApp->OnSpecialKeyDown(virtKey, xPos, yPos);
}
return 0;
}
case WM_KEYUP:
{
int virtKey = (int)wParam;
// get the cursor position in client coordinates
POINT point;
GetCursorPos(&point);
ScreenToClient(handle, &point);
int xPos = (int)point.x;
int yPos = (int)point.y;
if ((VK_F1 <= virtKey && virtKey <= VK_F12)
|| (VK_PRIOR <= virtKey && virtKey <= VK_DOWN)
|| (virtKey == VK_INSERT) || (virtKey == VK_DELETE)
|| (virtKey == VK_SHIFT) || (virtKey == VK_CONTROL))
{
theApp->OnSpecialKeyUp(virtKey, xPos, yPos);
}
else
{
theApp->OnKeyUp((unsigned char)virtKey, xPos, yPos);
}
return 0;
}
case WM_LBUTTONDOWN:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_LEFT_BUTTON,
WindowApplication::MOUSE_DOWN, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_LBUTTONUP:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_LEFT_BUTTON,
WindowApplication::MOUSE_UP, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_MBUTTONDOWN:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_MIDDLE_BUTTON,
WindowApplication::MOUSE_DOWN, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_MBUTTONUP:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_MIDDLE_BUTTON,
WindowApplication::MOUSE_UP, xPos, yPos, PtrToUint(wParam));
return 0;
}
case WM_RBUTTONDOWN:
{
int xPos = (int)(LOWORD(lParam));
int yPos = (int)(HIWORD(lParam));
theApp->OnMouseClick(WindowApplication::MOUSE_RIGHT_BUTTON,