support horizontal mouse wheel, use in text editor
This commit is contained in:
parent
cefca4429c
commit
df4faf8f33
6 changed files with 47 additions and 4 deletions
|
@ -317,16 +317,19 @@ static _GlobalConstant _global_constants[]={
|
|||
BIND_GLOBAL_CONSTANT( KEY_MASK_KPAD ),
|
||||
BIND_GLOBAL_CONSTANT( KEY_MASK_GROUP_SWITCH ),
|
||||
|
||||
// joysticks
|
||||
// mouse
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MIDDLE ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_UP ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_DOWN ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_WHEEL_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_LEFT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_RIGHT ),
|
||||
BIND_GLOBAL_CONSTANT( BUTTON_MASK_MIDDLE ),
|
||||
|
||||
//joysticks
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_0 ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_1 ),
|
||||
BIND_GLOBAL_CONSTANT( JOY_BUTTON_2 ),
|
||||
|
|
|
@ -51,6 +51,8 @@ enum {
|
|||
BUTTON_MIDDLE=3,
|
||||
BUTTON_WHEEL_UP=4,
|
||||
BUTTON_WHEEL_DOWN=5,
|
||||
BUTTON_WHEEL_LEFT=6,
|
||||
BUTTON_WHEEL_RIGHT=7,
|
||||
BUTTON_MASK_LEFT=(1<<(BUTTON_LEFT-1)),
|
||||
BUTTON_MASK_RIGHT=(1<<(BUTTON_RIGHT-1)),
|
||||
BUTTON_MASK_MIDDLE=(1<<(BUTTON_MIDDLE-1)),
|
||||
|
|
|
@ -809,6 +809,21 @@ static int translateKey(unsigned int key)
|
|||
OS_OSX::singleton->push_input(ev);
|
||||
}
|
||||
|
||||
if (fabs(deltaX)) {
|
||||
|
||||
InputEvent ev;
|
||||
ev.type=InputEvent::MOUSE_BUTTON;
|
||||
ev.mouse_button.button_index=deltaX >0 ? BUTTON_WHEEL_RIGHT : BUTTON_WHEEL_LEFT;
|
||||
ev.mouse_button.pressed=true;
|
||||
ev.mouse_button.x=mouse_x;
|
||||
ev.mouse_button.y=mouse_y;
|
||||
ev.mouse_button.global_x=mouse_x;
|
||||
ev.mouse_button.global_y=mouse_y;
|
||||
ev.mouse_button.button_mask=button_mask;
|
||||
OS_OSX::singleton->push_input(ev);
|
||||
ev.mouse_button.pressed=false;
|
||||
OS_OSX::singleton->push_input(ev);
|
||||
}
|
||||
}
|
||||
|
||||
@end
|
||||
|
|
|
@ -66,6 +66,10 @@ extern "C" {
|
|||
#endif
|
||||
}
|
||||
|
||||
#ifndef WM_MOUSEHWHEEL
|
||||
#define WM_MOUSEHWHEEL 0x020e
|
||||
#endif
|
||||
|
||||
//#define STDOUT_FILE
|
||||
|
||||
extern HINSTANCE godot_hinstance;
|
||||
|
@ -432,6 +436,7 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||
case WM_RBUTTONDOWN:
|
||||
case WM_RBUTTONUP:
|
||||
case WM_MOUSEWHEEL:
|
||||
case WM_MOUSEHWHEEL:
|
||||
case WM_LBUTTONDBLCLK:
|
||||
case WM_RBUTTONDBLCLK:
|
||||
/*case WM_XBUTTONDOWN:
|
||||
|
@ -502,11 +507,23 @@ LRESULT OS_Windows::WndProc(HWND hWnd,UINT uMsg, WPARAM wParam, LPARAM lParam) {
|
|||
|
||||
|
||||
if (motion>0)
|
||||
mb.button_index=4;
|
||||
mb.button_index= BUTTON_WHEEL_UP;
|
||||
else
|
||||
mb.button_index=5;
|
||||
mb.button_index= BUTTON_WHEEL_DOWN;
|
||||
|
||||
|
||||
} break;
|
||||
case WM_MOUSEHWHEEL: {
|
||||
|
||||
mb.pressed = true;
|
||||
int motion = (short)HIWORD(wParam);
|
||||
if (!motion)
|
||||
return 0;
|
||||
|
||||
if (motion<0)
|
||||
mb.button_index = BUTTON_WHEEL_LEFT;
|
||||
else
|
||||
mb.button_index = BUTTON_WHEEL_RIGHT;
|
||||
} break;
|
||||
/*
|
||||
case WM_XBUTTONDOWN: {
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
#ifndef OS_WINDOWS_H
|
||||
#define OS_WINDOWS_H
|
||||
|
||||
#define WINVER 0x0500
|
||||
#define WINVER 0x0600
|
||||
|
||||
#include "os/input.h"
|
||||
#include "os/os.h"
|
||||
|
|
|
@ -1197,6 +1197,12 @@ void TextEdit::_input_event(const InputEvent& p_input_event) {
|
|||
if (mb.button_index==BUTTON_WHEEL_DOWN) {
|
||||
v_scroll->set_val( v_scroll->get_val() +3 );
|
||||
}
|
||||
if (mb.button_index==BUTTON_WHEEL_LEFT) {
|
||||
h_scroll->set_val( h_scroll->get_val() -3 );
|
||||
}
|
||||
if (mb.button_index==BUTTON_WHEEL_RIGHT) {
|
||||
h_scroll->set_val( h_scroll->get_val() +3 );
|
||||
}
|
||||
if (mb.button_index==BUTTON_LEFT) {
|
||||
|
||||
int row,col;
|
||||
|
|
Loading…
Reference in a new issue