Give keyboard focus to UI on each mouse click
This commit is contained in:
parent
76b18507f2
commit
a0faebad8b
1 changed files with 8 additions and 11 deletions
|
|
@ -298,7 +298,7 @@ class CardinalUI : public CardinalBaseUI,
|
||||||
rack::math::Vec lastMousePos;
|
rack::math::Vec lastMousePos;
|
||||||
WindowParameters windowParameters;
|
WindowParameters windowParameters;
|
||||||
int rateLimitStep = 0;
|
int rateLimitStep = 0;
|
||||||
int8_t counterForSelfFocus = 0;
|
int8_t counterForFirstIdlePoint = 0;
|
||||||
|
|
||||||
struct ScopedContext {
|
struct ScopedContext {
|
||||||
CardinalPluginContext* const context;
|
CardinalPluginContext* const context;
|
||||||
|
|
@ -428,10 +428,9 @@ public:
|
||||||
|
|
||||||
void uiIdle() override
|
void uiIdle() override
|
||||||
{
|
{
|
||||||
if (counterForSelfFocus >= 0 && ++counterForSelfFocus == 5)
|
if (counterForFirstIdlePoint >= 0 && ++counterForFirstIdlePoint == 5)
|
||||||
{
|
{
|
||||||
counterForSelfFocus = -1;
|
counterForFirstIdlePoint = -1;
|
||||||
getWindow().focus();
|
|
||||||
|
|
||||||
#ifdef DISTRHO_OS_WASM
|
#ifdef DISTRHO_OS_WASM
|
||||||
if (rack::patchStorageSlug != nullptr)
|
if (rack::patchStorageSlug != nullptr)
|
||||||
|
|
@ -690,6 +689,9 @@ protected:
|
||||||
|
|
||||||
bool onMouse(const MouseEvent& ev) override
|
bool onMouse(const MouseEvent& ev) override
|
||||||
{
|
{
|
||||||
|
if (ev.press)
|
||||||
|
getWindow().focus();
|
||||||
|
|
||||||
const int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
const int action = ev.press ? GLFW_PRESS : GLFW_RELEASE;
|
||||||
int mods = glfwMods(ev.mod);
|
int mods = glfwMods(ev.mod);
|
||||||
|
|
||||||
|
|
@ -850,14 +852,9 @@ protected:
|
||||||
setState("windowSize", sizeString);
|
setState("windowSize", sizeString);
|
||||||
}
|
}
|
||||||
|
|
||||||
void uiFocus(const bool focus, const CrossingMode mode) override
|
void uiFocus(const bool focus, CrossingMode) override
|
||||||
{
|
{
|
||||||
if (focus)
|
if (!focus)
|
||||||
{
|
|
||||||
if (mode == kCrossingNormal)
|
|
||||||
getWindow().focus();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
const ScopedContext sc(this, 0);
|
const ScopedContext sc(this, 0);
|
||||||
context->event->handleLeave();
|
context->event->handleLeave();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue