Skip to content

Commit

Permalink
- fix #570
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph-hart committed Sep 30, 2024
1 parent c08142b commit ff009c8
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 14 deletions.
2 changes: 1 addition & 1 deletion currentGitHash.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
56f5d952eaa1a4f4977e0330fbfdc3dfc2806b6f
c08142b60dfc4ea71c335649649cda259c492d3b
2 changes: 1 addition & 1 deletion hi_backend/backend/currentGit.h
Original file line number Diff line number Diff line change
@@ -1 +1 @@
#define PREVIOUS_HISE_COMMIT "56f5d952eaa1a4f4977e0330fbfdc3dfc2806b6f"
#define PREVIOUS_HISE_COMMIT "c08142b60dfc4ea71c335649649cda259c492d3b"
23 changes: 12 additions & 11 deletions hi_scripting/scripting/api/ScriptingApiContent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1595,8 +1595,7 @@ void ScriptComponent::setConsumedKeyPresses(var listOfKeys)

if(listOfKeys.isArray())
{
catchAllKeys = false;

catchAllKeys = AllCatchBehaviour::Inactive;
for(const auto& v: *listOfKeys.getArray())
{
auto k = ApiHelpers::getKeyPress(v, &r);
Expand All @@ -1611,15 +1610,19 @@ void ScriptComponent::setConsumedKeyPresses(var listOfKeys)
{
if(listOfKeys.toString() == "all")
{
catchAllKeys = true;
catchAllKeys = AllCatchBehaviour::Exclusive;
}
else if(listOfKeys.toString() == "all_nonexclusive")
{
catchAllKeys = AllCatchBehaviour::NonExlusive;
}
else
{
auto k = ApiHelpers::getKeyPress(listOfKeys, &r);

if(r.wasOk())
{
catchAllKeys = false;
catchAllKeys = AllCatchBehaviour::Inactive;
registeredKeys.add(k);
}
else
Expand All @@ -1636,18 +1639,16 @@ bool ScriptingApi::Content::ScriptComponent::handleKeyPress(const KeyPress& k)
{
if (keyboardCallback)
{
if(catchAllKeys || registeredKeys.contains(k))
auto matchesKey = registeredKeys.contains(k);

if((catchAllKeys != AllCatchBehaviour::Inactive) || matchesKey)
{
auto args = Content::createKeyboardCallbackObject(k);

var rv;

keyboardCallback.call(&args, 1);

return true;
bool consumed = matchesKey || catchAllKeys == AllCatchBehaviour::Exclusive;
return consumed;
}


}

return false;
Expand Down
9 changes: 8 additions & 1 deletion hi_scripting/scripting/api/ScriptingApiContent.h
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,13 @@ class ScriptingApi::Content : public ScriptingObject,

private:

enum class AllCatchBehaviour
{
Inactive,
Exclusive,
NonExlusive
};

int pseudoState = 0;

void sendValueListenerMessage();
Expand All @@ -767,7 +774,7 @@ class ScriptingApi::Content : public ScriptingObject,
MacroControlledObject::ModulationPopupData::Ptr modulationData;

bool consumedCalled = false;
bool catchAllKeys = true;
AllCatchBehaviour catchAllKeys = AllCatchBehaviour::Exclusive;
Array<juce::KeyPress> registeredKeys;

WeakCallbackHolder keyboardCallback;
Expand Down

0 comments on commit ff009c8

Please sign in to comment.