Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Clark Lin
hw3d
Commits
79f9c623
Commit
79f9c623
authored
Mar 03, 2019
by
chili
Browse files
imgui input capture/stifle
parent
dbee5401
Changes
1
Show whitespace changes
Inline
Side-by-side
hw3d/Window.cpp
View file @
79f9c623
...
...
@@ -183,6 +183,7 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
{
return
true
;
}
const
auto
imio
=
ImGui
::
GetIO
();
switch
(
msg
)
{
...
...
@@ -200,6 +201,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
case
WM_KEYDOWN
:
// syskey commands need to be handled to track ALT key (VK_MENU) and F10
case
WM_SYSKEYDOWN
:
// stifle this keyboard message if imgui wants to capture
if
(
imio
.
WantCaptureKeyboard
)
{
break
;
}
if
(
!
(
lParam
&
0x40000000
)
||
kbd
.
AutorepeatIsEnabled
()
)
// filter autorepeat
{
kbd
.
OnKeyPressed
(
static_cast
<
unsigned
char
>
(
wParam
)
);
...
...
@@ -207,9 +213,19 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
break
;
case
WM_KEYUP
:
case
WM_SYSKEYUP
:
// stifle this keyboard message if imgui wants to capture
if
(
imio
.
WantCaptureKeyboard
)
{
break
;
}
kbd
.
OnKeyReleased
(
static_cast
<
unsigned
char
>
(
wParam
)
);
break
;
case
WM_CHAR
:
// stifle this keyboard message if imgui wants to capture
if
(
imio
.
WantCaptureKeyboard
)
{
break
;
}
kbd
.
OnChar
(
static_cast
<
unsigned
char
>
(
wParam
)
);
break
;
/*********** END KEYBOARD MESSAGES ***********/
...
...
@@ -217,6 +233,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
/************* MOUSE MESSAGES ****************/
case
WM_MOUSEMOVE
:
{
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
// in client region -> log move, and log enter + capture mouse (if not previously in window)
if
(
pt
.
x
>=
0
&&
pt
.
x
<
width
&&
pt
.
y
>=
0
&&
pt
.
y
<
height
)
...
...
@@ -246,19 +267,34 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
}
case
WM_LBUTTONDOWN
:
{
SetForegroundWindow
(
hWnd
);
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
mouse
.
OnLeftPressed
(
pt
.
x
,
pt
.
y
);
SetForegroundWindow
(
hWnd
);
break
;
}
case
WM_RBUTTONDOWN
:
{
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
mouse
.
OnRightPressed
(
pt
.
x
,
pt
.
y
);
break
;
}
case
WM_LBUTTONUP
:
{
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
mouse
.
OnLeftReleased
(
pt
.
x
,
pt
.
y
);
// release mouse if outside of window
...
...
@@ -271,6 +307,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
}
case
WM_RBUTTONUP
:
{
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
mouse
.
OnRightReleased
(
pt
.
x
,
pt
.
y
);
// release mouse if outside of window
...
...
@@ -283,6 +324,11 @@ LRESULT Window::HandleMsg( HWND hWnd,UINT msg,WPARAM wParam,LPARAM lParam ) noex
}
case
WM_MOUSEWHEEL
:
{
// stifle this mouse message if imgui wants to capture
if
(
imio
.
WantCaptureMouse
)
{
break
;
}
const
POINTS
pt
=
MAKEPOINTS
(
lParam
);
const
int
delta
=
GET_WHEEL_DELTA_WPARAM
(
wParam
);
mouse
.
OnWheelDelta
(
pt
.
x
,
pt
.
y
,
delta
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment