Merge pull request #277 from dariomanesku/master
Added mouse scroll support for OSX.
This commit is contained in:
Коммит
eca80d1214
|
@ -16,9 +16,6 @@
|
||||||
#include <bx/os.h>
|
#include <bx/os.h>
|
||||||
#include <bx/handlealloc.h>
|
#include <bx/handlealloc.h>
|
||||||
|
|
||||||
#define DEFAULT_WIDTH 1280
|
|
||||||
#define DEFAULT_HEIGHT 720
|
|
||||||
|
|
||||||
@interface AppDelegate : NSObject<NSApplicationDelegate>
|
@interface AppDelegate : NSObject<NSApplicationDelegate>
|
||||||
{
|
{
|
||||||
bool terminated;
|
bool terminated;
|
||||||
|
@ -80,7 +77,8 @@ namespace entry
|
||||||
struct Context
|
struct Context
|
||||||
{
|
{
|
||||||
Context()
|
Context()
|
||||||
: m_exit(false)
|
: m_scroll(0)
|
||||||
|
, m_exit(false)
|
||||||
{
|
{
|
||||||
s_translateKey[27] = Key::Esc;
|
s_translateKey[27] = Key::Esc;
|
||||||
s_translateKey[13] = Key::Return;
|
s_translateKey[13] = Key::Return;
|
||||||
|
@ -236,10 +234,11 @@ namespace entry
|
||||||
case NSMouseMoved:
|
case NSMouseMoved:
|
||||||
case NSLeftMouseDragged:
|
case NSLeftMouseDragged:
|
||||||
case NSRightMouseDragged:
|
case NSRightMouseDragged:
|
||||||
|
case NSOtherMouseDragged:
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
getMousePos(&x, &y);
|
getMousePos(&x, &y);
|
||||||
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0);
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -247,7 +246,7 @@ namespace entry
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
getMousePos(&x, &y);
|
getMousePos(&x, &y);
|
||||||
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, true);
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -255,7 +254,7 @@ namespace entry
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
getMousePos(&x, &y);
|
getMousePos(&x, &y);
|
||||||
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Left, false);
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Left, false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -263,7 +262,7 @@ namespace entry
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
getMousePos(&x, &y);
|
getMousePos(&x, &y);
|
||||||
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, true);
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -271,7 +270,32 @@ namespace entry
|
||||||
{
|
{
|
||||||
int x, y;
|
int x, y;
|
||||||
getMousePos(&x, &y);
|
getMousePos(&x, &y);
|
||||||
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, 0, MouseButton::Right, false);
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Right, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case NSOtherMouseDown:
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
getMousePos(&x, &y);
|
||||||
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Middle, true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case NSOtherMouseUp:
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
getMousePos(&x, &y);
|
||||||
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll, MouseButton::Middle, false);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case NSScrollWheel:
|
||||||
|
{
|
||||||
|
int x, y;
|
||||||
|
getMousePos(&x, &y);
|
||||||
|
m_scroll += ([event deltaY] > 0.0f) ? 1 : -1;
|
||||||
|
m_eventQueue.postMouseEvent(s_defaultWindow, x, y, m_scroll);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -364,7 +388,7 @@ namespace entry
|
||||||
[NSApp setMainMenu:menubar];
|
[NSApp setMainMenu:menubar];
|
||||||
|
|
||||||
m_windowAlloc.alloc();
|
m_windowAlloc.alloc();
|
||||||
NSRect rect = NSMakeRect(0, 0, DEFAULT_WIDTH, DEFAULT_HEIGHT);
|
NSRect rect = NSMakeRect(0, 0, ENTRY_DEFAULT_WIDTH, ENTRY_DEFAULT_HEIGHT);
|
||||||
NSWindow* window = [[NSWindow alloc]
|
NSWindow* window = [[NSWindow alloc]
|
||||||
initWithContentRect:rect
|
initWithContentRect:rect
|
||||||
styleMask:0
|
styleMask:0
|
||||||
|
@ -419,6 +443,7 @@ namespace entry
|
||||||
bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc;
|
bx::HandleAllocT<ENTRY_CONFIG_MAX_WINDOWS> m_windowAlloc;
|
||||||
NSWindow* m_window[ENTRY_CONFIG_MAX_WINDOWS];
|
NSWindow* m_window[ENTRY_CONFIG_MAX_WINDOWS];
|
||||||
|
|
||||||
|
int32_t m_scroll;
|
||||||
bool m_exit;
|
bool m_exit;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче